figure;
histogram = hist(np,180);
name=['histogram-' int2str(k) '.png'];
%% k is the iterator so basically I want to save all the images using a loop.
imwrite(out,name);
我得到的图像只是一条水平线。有人知道如何解决这个问题吗?
答案 0 :(得分:1)
你可以使用savefig而不是imwrite
这是doc http://www.mathworks.ch/ch/help/matlab/ref/savefig.html
savefig(h,filename)
h是图的句柄。你可以跳过h来保存当前数字。
(编辑)savefig可能不存在,具体取决于MATLAB版本。在2012b,它不会退出。
所以saveas可能会更好:
f=figure;
hist([1 2 2 3]);
saveas(f, 'histogram-1.png')
这在MATALB 2012b中有效。您也可以将其保存为.fig。