How to index a random matrix with set conditions?

1 次查看(过去 30 天)
How can I find elements within a random matrix M (5x5) that are negative or are between 20 and 40?

采纳的回答

Are Mjaavatten
Are Mjaavatten 2019-1-14
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 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

产品


版本

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by