count bins

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.
It appears the equivalent would be
histc(dataX(:), -5*sX:step:5*sX)
but watch out for the boundary conditions.
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.
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 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by