Binning Data

8 次查看(过去 30 天)
Katherine Anderson
Katherine Anderson 2011-7-31
Hi All,
My question should be fairly simple, but somehow its perplexing me. I have a vector Mw=[5.7593;5.8340;5.9009;5.8001;5.8563]. I want to bin the vector into increments of 0.05 and be able to see which values are inside each bin. I tried the hist function but I will eventually have more data and won't know exactly how many bins I will need. I'd just like be able to bin it within that increment no matter what the data set is. Any suggestions?
thanks,
KL

回答(2 个)

Image Analyst
Image Analyst 2011-7-31
Then use the function histc(). You don't need to specify how many bins you'll need. You only need to specify the edges. And by examining the min and max value of your array, you'll have a starting and ending point for the edges array. Of course at that point you'll also know how many 0.05-wide bins you're going to be using.

Walter Roberson
Walter Roberson 2011-7-31
One interpretation:
[B,I,J] = unique(fix(Mw(:) * 20)/20);
sortrows([B(J),Mw(:)])
You have not been clear as to what output you were hoping to see.

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by