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

20 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 22 de Ag. de 2016
A(A==0)=inf
[~,idx]=min(A)

Más respuestas (0)

Categorías

Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by