Find the index of the lowest number greater than zero in a vector

19 vues (au cours des 30 derniers jours)
Erik Lenstrup
Erik Lenstrup le 22 Août 2016
Commenté : Erik Lenstrup le 22 Août 2016
I would like to find the index of the lowest number greater than zero in a vector. ex: [0,0,4,5,0] The answer should be 3 because 4 is the third element.

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 22 Août 2016
A(A==0)=inf
[~,idx]=min(A)

Plus de réponses (0)

Catégories

En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by