MATLAB Answers

How to index a random matrix with set conditions?

조회 수: 8(최근 30일)
adena0
adena0 14 Jan 2019
답변: Are Mjaavatten 14 Jan 2019
How can I find elements within a random matrix M (5x5) that are negative or are between 20 and 40?

  댓글 수: 0

댓글을 달려면 로그인하십시오.

채택된 답변

Are Mjaavatten
Are Mjaavatten 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

댓글을 달려면 로그인하십시오.

추가 답변(0개)

제품


릴리스

R2018a

Translated by