MATLAB: Save a figure as pdf

figyurepdf

I have figures and I am using the command below to save it as pdf. Is there any way to save it directly as pdf instead of saving as .ps and convert to .pdf.
print(figure(i), '-append', '-dpsc2', 'E:\myfigure.ps');
Thanks

Best Answer

saveas(gcf,'myfigure.pdf')
Or
set(gcf,'Units','inches');
screenposition = get(gcf,'Position');
set(gcf,...
'PaperPosition',[0 0 screenposition(3:4)],...
'PaperSize',[screenposition(3:4)]);
print -dpdf -painters epsFig
The first two lines measure the size of your figure (in inches). The next line configures the print paper size to fit the figure size. The last line uses the print command and exports a vector pdf document as the output.
Related Question