finding the last element of an array that fulfils a condition

10 visualizaciones (últimos 30 días)
Ach
Ach el 24 de Mayo de 2018
Respondida: Walter Roberson el 24 de Mayo de 2018
hi , i want to calculate the difference inside a loop: diff=0.0002; for i=1:length(k) if diff(i)<=diff result=i; end end i want to save the last i (condition fulfilled) and not to the first one . Is that possible?

Respuestas (1)

Walter Roberson
Walter Roberson el 24 de Mayo de 2018
Use find() with the 'last' option

Categorías

Más información sobre Matrices and Arrays 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