finding value less than a threshold
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Walter Roberson
le 9 Mai 2011
sum(A(:)<6)
3 commentaires
RoJo
le 9 Mai 2011
>> 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
le 9 Mai 2011
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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!