Is there a way to count the integers in a matrix that fall within a certain range?
조회 수: 5 (최근 30일)
이전 댓글 표시
I am working on a problem that gives me a 3x10 matrix with numbers ranging from 1 to 100. I want to count the number of integers that fall within a ceratin catagory such as 0 to 19, 20 to 39, 40 to 59, etc. Is there a way for me to find the sum of integers within these specific ranges? I'm still very new to MatLab. Thank you.
댓글 수: 1
답변 (2개)
Matt J
2022년 2월 9일
Yes, you can use histcounts.
counts=histcounts(yourMatrix(:),[0,20,40,60])
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!