How can I find the elements of a matrix that are lower than a given number and the minimum of those elements?

조회 수: 4 (최근 30일)

채택된 답변

Stephan
Stephan 2018년 8월 28일
편집: Stephan 2018년 8월 28일
Hi,
A = hilb(70);
B = A(A < 0.01); % copy all elements <0.01 into vector B;
C = min(B) % get the min value from B
D = min(min(A)) % same result like C, but directly taken from A
Best regards
Stephan

추가 답변 (1개)

Arthur Nascimento
Arthur Nascimento 2018년 8월 28일
편집: Arthur Nascimento 2018년 8월 28일
To get the indexes of the elements lower than a number you can do:
A = hilb(70);
A<0.01
If you want the value of said elements you can do
A(A<.01)
To find the index of the minimum element you can use
A(A==min(A))
Or the element
min(A)
  댓글 수: 1
Stephan
Stephan 2018년 8월 28일
편집: Stephan 2018년 8월 28일
Note that if A is a matrix, then min(A) is a row vector containing the minimum value of each column.
So
min(A)
will not give the smallest one element from A but a 1x70 vector.
Also note that:
A(A==min(A))
does not give back indices, but a transposed version of the vector made by min(A) with dimensions 70x1.

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

카테고리

Help CenterFile Exchange에서 Hilbert and Walsh-Hadamard Transforms에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by