finding the last element of an array that fulfils a condition

10 次查看(过去 30 天)
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?

回答(1 个)

Walter Roberson
Walter Roberson 2018-5-24
Use find() with the 'last' option

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by