How to perform the following commands?

1 Ansicht (letzte 30 Tage)
M
M am 24 Mai 2022
Beantwortet: Walter Roberson am 24 Mai 2022
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 Kommentare
M
M am 24 Mai 2022
Bearbeitet: M am 24 Mai 2022
@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 am 24 Mai 2022
create a temporary vector that is abs() and replace 0 values with nan and min() that.
Or loop.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 24 Mai 2022
temp = abs(result1(1,:));
temp(temp==0) = nan;
[~, idx] = min(temp) ;

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by