First minimum larger than zero

6 次查看(过去 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