Binning Data
8 views (last 30 days)
Show older comments
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
0 Comments
Answers (2)
Image Analyst
on 31 Jul 2011
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.
0 Comments
Walter Roberson
on 31 Jul 2011
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.
0 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!