[英]How to plot a histogram in MATLAB?
I have one vector ( newdata
) consisting of 4100 lines and one column. 我有一个矢量(
newdata
)由4100行和一列组成。 To be exact, those elements are the counts of a spectrum. 确切地说,这些元素是频谱的计数。 What I want is to reproduce the spectrum using MATLAB.
我想要的是使用MATLAB重现光谱。 That's why I created a new vector:
这就是我创建一个新向量的原因:
channels=[1:size(newdata,1)];
I tried to plot the spectrum (using channel
in x axis and newdata
as a weight) by typing: 我试图绘制光谱(使用
channel
在x轴和newdata
通过键入作为权重):
hist(channels,newdata)
But I got an error 但是我收到了一个错误
??? Error using ==> histc
Edges vector must be monotonically non-decreasing.
Error in ==> hist at 86
nn = histc(y,[-inf bins],1);
How can I draw the desired spectrum? 如何绘制所需的光谱?
尝试使用bar
命令进行绘图
bar( channels, newData );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.