First minimum larger than zero

4 vues (au cours des 30 derniers jours)
ph
ph le 7 Fév 2022
Commenté : ph le 7 Fév 2022
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

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by