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

8 Ansichten (letzte 30 Tage)
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.

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 22 Aug. 2016
A(A==0)=inf
[~,idx]=min(A)

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by