How to bin data into intervals?

Hi! I have a vector that I want to group into intervals so that the values are greater than 50 but less than 500 apart in each interval and omit numbers that do not fall in this range. For example if I had vector [5 50 400 1000 1200] I would want to separate this into [50 400] and [1000 1200]. How can I do this? Thank you!

 Risposta accettata

I would do this:
D = randi(1300, 1, 250); % Create Data
hc = histcounts(D, [50 400 1000 1200]); % Ask ‘histcounts’
Result = hc([1 3]); % Return Requested Intervals

2 Commenti

thank you!
As always, my pleasure!

Accedi per commentare.

Più risposte (0)

Categorie

Community Treasure Hunt

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

Start Hunting!

Translated by