how can we represent the histogram of a vector without using the hist function ?

조회 수: 2 (최근 30일)
hi every body how can I represent the histogram of a data vector without using the hist function ? thanks
  댓글 수: 1
Cedric
Cedric 2013년 5월 12일
편집: Cedric 2013년 5월 12일
Yet another series of hints:
doc accumarray
You could think of a solution where you generate the subs argument by using CEIL on the quotient of your dataset and a relevant factor (related to the size of bins); and you use a vector of ones (sized appropriately) as the val argument.

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

답변 (6개)

the cyclist
the cyclist 2013년 5월 11일
You could use the bar() function.

jan
jan 2013년 5월 11일
no what i mean that i dont want to represent it with bars but only line that represent the distribution of my data(in vector)

Image Analyst
Image Analyst 2013년 5월 11일
You would essentially have to program up the internals of the histogram function yourself. Very, very easy to do, once you've decided on your bin edge locations. Just think it through in your head and I'm sure you'll know what the code needs to be. It's fairly trivial, so you probably won't need any help.

Andrei Bobrov
Andrei Bobrov 2013년 5월 11일
eg
X = randi(20,40,1);
ii = [-inf 0:4:20 inf]
out = sum(bsxfun(@lt,X,ii(2:end))&bsxfun(@ge,X,ii(1:end-1)))
histc(X,ii)

jan
jan 2013년 5월 11일
THANKS andrei Bobrov for the response but i need not to use the histc function because i want to represent my data without bars only line
  댓글 수: 2
Image Analyst
Image Analyst 2013년 5월 11일
This should have been a comment to Andrei, rather than an "Answer" to your original question. So am I to assume that programming up your own histogram, like I suggested, is too challenging for you?
Randy Souza
Randy Souza 2013년 5월 14일
I deleted two less-than-constructive comments here.
@jan: It really makes it easier for other people to follow if, as Image Analyst suggests, you add your reply to an answer as a comment, rather than as a new answer.

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


Teja Muppirala
Teja Muppirala 2013년 5월 14일
Is it that you just don't want the bar graph that comes up with HIST? If you call it with output arguments, you can get the values without the bar graph.
Then you can just plot those as a line.
data = randn(1,10000);
[N,X] = hist(data,30);
plot(X,N)

카테고리

Help CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by