Finding the number of values bigger than a certain number in an array?
조회 수: 17 (최근 30일)
이전 댓글 표시
Suppose I have an array of 50 numbers, how would I find the number of elements bigger than say 21 in an array of random numbers? Conversely, for less than as well.
댓글 수: 0
채택된 답변
Tom
2012년 9월 26일
편집: Tom
2012년 9월 26일
x=50*rand(7);
a= x > 21;
numel(a(a>0))
댓글 수: 2
Image Analyst
2012년 9월 26일
편집: Andrei Bobrov
2012년 9월 26일
Or
numberBigger = sum(x(:)>21);
numberSmaller = sum(x(:)<=21);
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!