MATLAB Function Reference Previous page   Next Page
saveas

Save figure or model using specified format

Syntax

Description

saveas(h,'filename.ext') saves the figure or model 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.

ext Values
Format
ai
Adobe Illustrator `88
bmp
Windows bitmap
emf
Enhanced metafile
eps
EPS Level 1
fig
MATLAB figure (invalid for Simulink models)
jpg
JPEG image (invalid for Simulink models)
m
MATLAB M-file (invalid for Simulink models)
pbm
Portable bitmap
pcx
Paintbrush 24-bit
pgm
Portable Graymap
png
Portable Network Graphics
ppm
Portable Pixmap
tif
TIFF image, compressed

saveas(h,'filename','format') saves the figure or model 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 types supported by print. The print device types include the formats listed in the table of extensions above as well as additional file formats. Use an extension from the table above or from the list of device types supported by print. When using the print device type to specify format for saveas, do not use the prefixed -d.

Remarks

You can use open to open files saved using saveas with an m or fig extension. Other formats are not supported by open. The Save As dialog box you access from the figure window's File menu uses saveas, limiting the file extensions to m and fig. The Export dialog box you access from the figure window's File menu uses saveas with the format argument.

Examples

Example 1 - Specify File Extension

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.

Example 2 - Specify File Format but No Extension

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.

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.

Example 3 - Specify File Format and Extension

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.

In another example, save the current model 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.

See Also

open, print

Printing for related functions


Previous page  save saveobj Next page

© 1994-2005 The MathWorks, Inc.