Thanos
Thanos

Reputation: 586

How to plot a histogram in MATLAB?

I have one vector (newdata) consisting of 4100 lines and one column. To be exact, those elements are the counts of a spectrum. What I want is to reproduce the spectrum using 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:

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?

Upvotes: 0

Views: 9592

Answers (1)

Shai
Shai

Reputation: 114796

try plotting using the bar command

bar( channels, newData );

Upvotes: 2

Related Questions