MATLAB: How to save the content of the current figure as an image

digital image processingimageimage processingImage Processing Toolboxprogramming

how to save the content(which is an image) of the current figure as an image?
I have about 30 figure …
I want to use MATLAB commands to save them in for loop

Best Answer

saveas(gcf,'filename.png')
would also work.
or something like this
for i=1:30
% code to show image number i
saveas(gcf,['filename' num2str(i) '.png']);
end
if you don't like the border around it type:
iptsetpref('ImshowBorder','tight');
before preparing your figure.
Related Question