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!