First minimum larger than zero

조회 수: 5 (최근 30일)
ph
ph 2022년 2월 7일
댓글: ph 2022년 2월 7일
Hi,
I'd like to know the first index (and eventually the value) of the minimum element larger than zero in a vector.
Exemple : a=[14,9,4,-1,-6,-11,9,4,-1] , I look for "3" (and eventually the value = 4)
Any suggestion is kindly appreciated
thanks
ph

채택된 답변

KSSV
KSSV 2022년 2월 7일
a=[14,9,4,-1,-6,-11,9,4,-1] ;
[val,idx] = min(abs(a))
val = 1
idx = 4
  댓글 수: 5
KSSV
KSSV 2022년 2월 7일
Thanks is accepting/ voting the answer. :)
ph
ph 2022년 2월 7일
Okok, needed to figure it out. Then you can edit the first answer with the comment you did after ;-)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by