Saving Plots in Matlab - A Beginner's Guide

  • MATLAB
  • Thread starter MaxManus
  • Start date
  • Tags
    Matlab Plot
In summary, the conversation was about saving plots in different files using the command "print('-dpdf','plot n = %s'n)". However, the command resulted in an error and the person was advised to refer to the MATLAB documentation for exporting to various formats. It was also suggested to resize the plot before exporting to avoid pixelation.
  • #1
MaxManus
277
1
Hey, I am making some plots in a loop and I want to save the different plots in different files.

I am new to Matlab so I don't know what to do, I tried the command

print('-dpdf','plot n = %s'n)

,but that was an 'Unexpected MATLAB expression.'
 
Physics news on Phys.org
  • #2
Take a look through the pertinent MATLAB documentation page:
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/print.html

(Exporting to various formats is about half-way through).

Note that you should probably resize the plot (to, say, Letter or A4 size) prior to exporting, otherwise things may look rather pixellated (though there is an option for vector output).
 
  • #3
Thanks.
 

1. How do I save a plot in Matlab?

To save a plot in Matlab, you can use the "saveas" function. Simply pass in the figure handle and the desired file name with the appropriate file extension, such as ".png" or ".jpg". Example: saveas(figure_handle, 'my_plot.png')

2. Can I choose the size and resolution of the saved plot?

Yes, you can specify the size and resolution of the saved plot by using the "PaperPosition" and "PaperUnits" properties of the figure. Example: set(figure_handle, 'PaperPosition', [0 0 5 5], 'PaperUnits', 'inches')

3. What is the difference between saving a figure and saving a plot?

Saving a figure in Matlab saves the entire figure window, including axes, labels, and any other elements. Saving a plot, on the other hand, saves only the actual plot itself without any additional elements.

4. How can I save multiple plots in one file?

You can save multiple plots in one file by using the "subplot" function to create a grid of plots, and then saving the entire figure as described in question 1. You can also use the "print" function to save multiple plots in one file by specifying the file name and format.

5. What are some common file formats for saving plots in Matlab?

Some common file formats for saving plots in Matlab include .png, .jpg, .pdf, .fig, and .eps. You can also use the "print" function to save in other formats, such as .svg or .tiff.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
32
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
735
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
675
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
Back
Top