Search this blog!

Thursday, July 5, 2012

How to save/print MATLAB figure in a file?

Imagine I want to print/save a matlab figure into disk. May be I want to save it in PNG format. How do I do that?
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

file_handler=figure;
plot(randn(10,1));
print(file_handler,'-dpng', 'my_file_name.png');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Check your current folder. A file named my_file_name.png should be there!




No comments:

Post a Comment