How to bin data into intervals?

조회 수: 5 (최근 30일)
Natalie St. John
Natalie St. John 2018년 5월 12일
댓글: Star Strider 2018년 5월 13일
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!

채택된 답변

Star Strider
Star Strider 2018년 5월 12일
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
Natalie St. John
Natalie St. John 2018년 5월 13일
thank you!
Star Strider
Star Strider 2018년 5월 13일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by