How to perform the following commands?

조회 수: 1 (최근 30일)
M
M 2022년 5월 24일
답변: Walter Roberson 2022년 5월 24일
How to perform the following commands:
result1 = m(:,abs(m(2,:))< threshold ); .......... This line I want to exclude zero value also.(I mean if it zero ignore it and look at the next value)
[~,idx] = min(abs(result1(1,:))); ....... This line I want to exclude zero value also. (I mean if it zero ignore it and look at the next value)
  댓글 수: 3
M
M 2022년 5월 24일
편집: M 2022년 5월 24일
@Walter Roberson, what about the second line" [~,idx] = min(abs(result1(1,:))); "
I want to exclude zero value also from this, I mea take the next abs(min value) after zero?
Walter Roberson
Walter Roberson 2022년 5월 24일
create a temporary vector that is abs() and replace 0 values with nan and min() that.
Or loop.

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

채택된 답변

Walter Roberson
Walter Roberson 2022년 5월 24일
temp = abs(result1(1,:));
temp(temp==0) = nan;
[~, idx] = min(temp) ;

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 NaNs에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by