saveas
Save a figure to a specific file.
Syntax
saveas(h, file_name)
saveas(h, file_name, file_format)
saveas(..., [width height])
Inputs
- h
- The handle of a figure.
- file_name
- The name of the output file.
- file_format
- The format of the output file. Options include 'png', 'jpg', 'jpeg', 'bmp', and 'svg'. If omitted, the format will be extracted from the file name. The default file format is 'png'.
- width, height
- The dimensions of the exported image in pixels. If omitted, the exported image will have the same dimensions as the figure window.
Examples
f=figure;
plot(rand(1,100));
saveas(f, 'demo1');
f=figure;
plot(rand(1,100));
saveas(f, 'demo2.bmp');
f=figure;
plot(rand(1,100));
saveas(f, 'demo3', 'bmp');
f=figure;
plot(rand(1,100));
saveas(f, 'demo4', [500 500]);
f=figure;
plot(rand(1,100));
saveas(f, 'demo5', 'jpg', [1280 720]);