Hello, i need help in counting bins. I have this command in mathematica:
nBin = BinCounts[dataX, {-5 sX, 5 sX, step}]
,where datax is a matrix. How can i possible write it in matlab?

 채택된 답변

Matt Fig
Matt Fig 2011년 2월 12일

0 개 추천

I think you might need to use the HISTC function. Have a look at the help to see if it meets your needs.

댓글 수: 7

George
George 2011년 2월 12일
I 've looked it but the problem is that i must find the bin counts.In histc you must supply the number of bins if i understood it well.
Walter Roberson
Walter Roberson 2011년 2월 12일
It appears the equivalent would be
histc(dataX(:), -5*sX:step:5*sX)
but watch out for the boundary conditions.
Walter Roberson
Walter Roberson 2011년 2월 12일
No, in histc() you supply the bin boundaries. It is hist() that you can supply bin counts.
Matt Tearle
Matt Tearle 2011년 2월 13일
Both HIST and HISTC will return bin counts, for a given vector of bin divisions. The difference is whether you specify the bin edges or centers.
Walter Roberson
Walter Roberson 2011년 2월 13일
Yes, but hist() allows you to specify just the number of bins; hist(X) uses nbins = 10, hist(X,nbins) with nbins a scalar uses that number, hist(X,y) with y a vector uses the given y values as the centers of bins. The algorithm for determining the boundaries of the bins given the number of them is not described in the hist() documentation.
histc() has no mode in which one can give the number of bins: it can only be used in the mode where one specifies the edges of bins. histc(x,y) with y a scalar would count the number of values in x that are exactly equal to the scalar y, as in sum(x==y) .
George
George 2011년 2월 13일
The histc(datax(:), -5*sX:step:5*sX) worked just fine!Thank you!
Matt Tearle
Matt Tearle 2011년 2월 13일
@WR: sorry, I missed George's first comment, so I missed the context of the discussion. Another thing to add to wish list, I think...

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

추가 답변 (0개)

카테고리

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

태그

질문:

2011년 2월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by