本文介绍了如何将直方图保存到Matlab中的文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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);
我得到的图像只是一条水平线.有人知道如何解决这个问题吗?
The image I got is only a horizontal line. Does someone know how to fix this?
推荐答案
您可以使用savefig代替imwrite
you can use savefig instead of imwrite
这是文档 http://www.mathworks.ch/ch/help/matlab/ref/savefig.html
savefig(h,filename)
h是图形的句柄.您可以跳过h保存当前图形.
h is the handle of figure. you could skip h to save the current figure.
(edit)savefig可能不存在,具体取决于MATLAB版本.在2012b中,它不会退出.
(edit) savefig may not be there depending on the MATLAB version. In 2012b, it does not exit.
所以 saveas 可能更好:
f=figure;
hist([1 2 2 3]);
saveas(f, 'histogram-1.png')
在MATALB 2012b中工作.您也可以将其另存为.fig.
This worked in MATALB 2012b. You can save it as .fig too.
这篇关于如何将直方图保存到Matlab中的文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!