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 ExchangeMATLAB についてさらに検索

タグ

質問済み:

2011 年 2 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by