how to get the first index that satisfy my condition

4 views (last 30 days)
farimah zarghami
farimah zarghami on 7 Oct 2021
Edited: Walter Roberson on 7 Oct 2021
hey guyz
I solved a nonlinear eq using ode45 and got X and T as answer.
Im trying the find settling time of a system as follow
for j=1:length(T)
if abs(X(j))==0.05*(abs(X(end)))
break
end
st=j*(10/length(T))
end
I need the first j that satisfy my condition, but I cant get it. is there any idea how to fix this?
ps: the command find() did not work.

Answers (1)

David Hill
David Hill on 7 Oct 2021
j=find(abs(x)<=abs(.05*x(end)),1);%I think you need <=
  3 Comments
farimah zarghami
farimah zarghami on 7 Oct 2021
thank you so much dear Steven, your clue truely helped me.

Sign in to comment.

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!