| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
Use File > Save As on the figure window menu to access the Save As dialog, in which you can select a graphics format. For details, see Exporting in a Specific Graphics Format in the MATLAB Graphics documentation. Sizes of files written to image formats by this GUI and by saveas can differ due to disparate resolution settings.
saveas(h,'filename.ext')
saveas(h,'filename','format')
saveas(h,'filename.ext') saves the figure or Simulink block diagram with the handle h to the file filename.ext. The format of the file is determined by the extension, ext. Allowable values for ext are listed in this table.
You can pass the handle of any Handle Graphics object to saveas, which then saves the parent figure to the object you specified should h not be a figure handle. This means that saveas cannot save a subplot without also saving all subplots in its parent figure.
ext Value | Format |
|---|---|
| ai | Adobe® Illustrator `88 |
| bmp | Windows bitmap |
| emf | Enhanced metafile |
| eps | EPS Level 1 |
| fig | MATLAB figure (invalid for Simulink block diagrams) |
| jpg | JPEG image (invalid for Simulink block diagrams) |
| m | MATLAB M-file (invalid for Simulink block diagrams) |
| pbm | Portable bitmap |
| pcx | Paintbrush 24-bit |
Portable Document Format | |
| pgm | Portable Graymap |
| png | Portable Network Graphics |
| ppm | Portable Pixmap |
| tif | TIFF image, compressed |
saveas(h,'filename','format') saves the figure or Simulink block diagram with the handle h to the file called filename using the specified format. The filename can have an extension, but the extension is not used to define the file format. If no extension is specified, the standard extension corresponding to the specified format is automatically appended to the filename.
Allowable values for format are the extensions in the table above and the device drivers and graphic formats supported by print. The drivers and graphic formats supported by print include additional file formats not listed in the table above. When using a print device type to specify format for saveas, do not prefix it with -d.
You can use open to open files saved using saveas with an m or fig extension. Other saveas and print formats are not supported by open. Both the Save As and Export Setup dialog boxes that you access from a figure's File menu use saveas with the format argument, and support all device and file types listed above.
Note Whenever you specify a format for saving a figure with the Save As menu item , that file format is used again the next time you save that figure or a new one. If you do not want to save in the previously-used format, use Save As and be sure to set the Save as type drop-down menu to the kind of file you want to write. However, saving a figure with the saveas function and a format does not change the Save as type setting in the GUI. |
If you want to control the size or resolution of figures saved in image (bit-mapped) formats, such as BMP or JPG, use the print command and specify dots-per-inch resolution with the –r switch.
Save the current figure that you annotated using the Plot Editor to a file named pred_prey using the MATLAB fig format. This allows you to open the file pred_prey.fig at a later time and continue editing it with the Plot Editor.
saveas(gcf,'pred_prey.fig')
Save the current figure, using Adobe Illustrator format, to the file logo. Use the ai extension from the above table to specify the format. The file created is logo.ai.
saveas(gcf,'logo', 'ai')
This is the same as using the Adobe Illustrator format from the print devices table, which is -dill; use doc print or help print to see the table for print device types. The file created is logo.ai. MATLAB automatically appends the ai extension for an Illustrator format file because no extension was specified.
saveas(gcf,'logo', 'ill')
Save the current figure to the file star.eps using the Level 2 Color PostScript format. If you use doc print or help print, you can see from the table for print device types that the device type for this format is -dpsc2. The file created is star.eps.
saveas(gcf,'star.eps', 'psc2')
In another example, save the current Simulink block diagram to the file trans.tiff using the TIFF format with no compression. From the table for print device types, you can see that the device type for this format is -dtiffn. The file created is trans.tiff.
saveas(gcf,'trans.tiff', 'tiffn')
Printing for related functions
Simulink users, see also save_system
![]() | save (serial) | saveobj | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |