Problem creating a histogram

5 ビュー (過去 30 日間)
Tom
Tom 2012 年 11 月 21 日
Hello,
I am trying to create a histogram where each bin is the length of the increments in another vector. Can anyone explain what I'm doing wrong with:
histc(screenhit,x)
where screenhit is the vector I want a histogram of, and x is simply a vector of numbers in increments of 0.01.
Thanks.
  1 件のコメント
José-Luis
José-Luis 2012 年 11 月 21 日
編集済み: José-Luis 2012 年 11 月 21 日
What result did you get? What result did you expect? It would be much more efficient to answer your question knowing that. If you want a plot with histc, you need it to do it yourself. Read the documentation, there's an example there.

サインインしてコメントする。

回答 (2 件)

Matt J
Matt J 2012 年 11 月 21 日
You're not doing anything wrong.
  2 件のコメント
Tom
Tom 2012 年 11 月 21 日
I was getting a histogram when I used hist instead of histc. But as I understood it, it is easiest to set the size of each bin using histc. Unfortunately it returns nothing at all.
Matt J
Matt J 2012 年 11 月 21 日
編集済み: Matt J 2012 年 11 月 21 日
Well, nothing you've showed us looks suspicious, nor does it allow us to reproduce the problem.

サインインしてコメントする。


Image Analyst
Image Analyst 2012 年 11 月 21 日
Try this:
screenhit = randi(50, 1000, 1);
x = sort(50*rand(50,1)); % 50 random edges of bins
counts = histc(screenhit,x)
bar(counts, 'BarWidth', 1);
It certainly returns something!

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by