savefig

Save a figure to a .fig file.

Syntax

savefig()

savefig(h)

savefig(filename)

savefig(h, filename)

Inputs

h
The handle of a figure. If not given then the current figure will be saved.
Type: double | integer
Dimension: scalar
filename
The name of the output file. The file extension must be '.fig'. If a file name is not given then the figure will be saved as 'Untitled.fig'
Type: string
Dimension: scalar

Examples

Save a figure. No arguments passed to savefig:
h = figure;
lh = plot(rand(10,4));
lgh = legend({'Line 1','Line 2'});
% save the current figure to 'Untitled.fig'
savefig();
Set a file name:
h = figure;
x=[0:0.1:2*pi];
y=x;
z=sin(x')*cos(y);
s=surf(x, y, z);
savefig(h, 'surf.fig');

Comments

Any uicontrol elements of the figure will not be saved in a .fig file.