finding value less than a threshold
조회 수: 4 (최근 30일)
이전 댓글 표시
Hi, suppose I have a matrix A as follows:
A =
1 2 3
3 3 6
4 6 8
4 7 7
I need to find the number of values of matrix A having value less than 6.
How to do this?
Thanks in advance
댓글 수: 0
채택된 답변
Walter Roberson
2011년 5월 9일
sum(A(:)<6)
댓글 수: 3
RoJo
2011년 5월 9일
>> sum(A(A<6))
ans =
20
Your original question is phrased wrong though for the answer you wanted. Should be 'sum of values of matrix A'
Walter Roberson
2011년 5월 9일
RoJo is correct. Your original question asked for the *number* of values, and that is what I answered. RoJo's code is good if you want the total of those values.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!