[Matlab] Figure Commands
Save Figure
Source:
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/saveas.htmlhttp://www.mathworks.com/access/helpdesk/help/techdoc/ref/print.html
Syntax:
Method 1:
saveas(h,'filename','format')
Method 2: (Using print function which allows user-defined print size)
set(h, 'PaperUnits', 'points');
set(h, 'PaperSize', [width height] );
print -dformat -rresolution filename;
Example:
Method 1:
saveas(h, 'd:\temp\test.jpg'); %Automatically save it as a jpeg file
saveas(h, 'd:\temp\test.dat', 'fig'); % Force matlab to save it as a fig file
Method 2:
plot(sin(0:0.1/2*pi:2*pi));
% Set 'PaperPositionMode' to 'auto' so that the print function will not resize the figure
set(h, 'PaperPositionMode', 'auto' );
% Set 'PaperUnits' to 'points' so that the the paper size can be defined in points.
set(h, 'PaperUnits', 'points');
% Set 'PaperSize' to the desired size in points. For some reason the value of width and height will be 4/3 times in pixels in the output file when printing the file at screen resolution (using -r0).
set(h, 'PaperSize', [900 500]*3/4 );
% use '-djpeg' to print the file in jpeg format. Use -r0 to specify the print resolution equal to screen resolution.
print -djpeg -r0 'test.jpg'
Support formats:
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 Graphic
sppm: Portable Pixmap
tif: TIFF image, compressed
No comments:
Post a Comment