logical operation on matrix
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
(Return logical 0 or 1) if matrix A contains ten values between 500 and 600.
A=[1 2 3;4 5 6; 4 5 2]
A(A>[1:2:6])=true %SMALL NUMBERS FOR EXAMPLE
0 commentaires
Réponse acceptée
DGM
le 8 Mar 2022
I'm going to assume that the text question is what you're after:
A = randi([100 999],10,10) % a bunch of integers
mk = A>=500 & A<=600 %find locations in the specified range
has10inrange = nnz(mk)>=10 % are there at least 10 values in the range?
1 commentaire
Image Analyst
le 8 Mar 2022
Or if you want to know if "A contains ten values between 500 and 600"
has10inRange = nnz(mk) == 10 % has10inRange is true if there are exactly 10 values in the range.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical 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!