How to index a random matrix with set conditions?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
adena0
am 14 Jan. 2019
Beantwortet: Are Mjaavatten
am 14 Jan. 2019
How can I find elements within a random matrix M (5x5) that are negative or are between 20 and 40?
0 Kommentare
Akzeptierte Antwort
Are Mjaavatten
am 14 Jan. 2019
For a list of the negative values:
negM = M(M<0)
For the indices of the negative values:
[i,j] = find(M<0)
To display only the negative values in a matrix:
N = M;
N(N>=0) = 0
For values between 20 and 40
values = M(M>=20 & M<=40)
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices 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!