logical operation on matrix
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Faisal Al-Wazir
am 8 Mär. 2022
Kommentiert: Image Analyst
am 8 Mär. 2022
(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 Kommentare
Akzeptierte Antwort
DGM
am 8 Mär. 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 Kommentar
Image Analyst
am 8 Mär. 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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!