如何在MATLAB中绘制直方图?

时间:2013-04-28 09:33:39

标签: matlab plot histogram

我有一个向量(newdata)由4100行和一列组成。确切地说,这些元素是频谱的计数。我想要的是使用MATLAB重现光谱。这就是我创建新矢量的原因:

channels=[1:size(newdata,1)];

我尝试通过输入以下内容绘制光谱(使用x轴中的channelnewdata作为权重):

hist(channels,newdata)

但我收到了错误

??? Error using ==> histc
Edges vector must be monotonically non-decreasing.

Error in ==> hist at 86
    nn = histc(y,[-inf bins],1);

如何绘制所需的光谱?

1 个答案:

答案 0 :(得分:2)

尝试使用bar命令进行绘图

bar( channels, newData );