Using the new histogram command with 'probability' normalisation

Hello,
I am trying to use the histogram command. I have 2 problems, one of them is minor, but the other is really holding me back at the moment
(1): The help site of the command http://uk.mathworks.com/help/matlab/ref/histogram.html says that
h = histogram(x)
will automatically display the histogram (I am using 2015a). For me it just creates the structure without displaying the histogram itself. I am using separately the bar command - - bar(h.bins,h.allData.counts) - to display the results. This is not a big trouble, but wonder if the documentation is wrong or if I am doing something wrong
(2): More importantly when I try to normalise the histogram with respect to the probability, then I get the following error:
x = randn(1000,1);
h = histogram(x,'Normalization','probability')
In an assignment A(I) = B, the
number of elements in B and I must
be the same.
Error in linspace (line 33)
y(1) = d1;
Error in histogram (line 193)
bins = linspace(minEdge +
halfResolution, maxEdge -
halfResolution, ...
Note that I have used the same example as the documentiation does. Any suggestions how to resolve it?
Best,
B

 채택된 답변

Guillaume
Guillaume 2016년 1월 15일
My guess is that you have another histogram function somewhere on your path. What does
which histogram
returns?

댓글 수: 1

you are right... i had an other histogram in a package that i was not aware of. now that it is off the path everything works as expected

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Histograms에 대해 자세히 알아보기

태그

질문:

2016년 1월 15일

댓글:

2016년 1월 15일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by