finding the last element of an array that fulfils a condition

10 visualizzazioni (ultimi 30 giorni)
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?

Risposte (1)

Walter Roberson
Walter Roberson il 24 Mag 2018
Use find() with the 'last' option

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by