vendredi 23 décembre 2016

Find time that a condition happens in ode45 - MATLAB

Say I have a set of 4 odes and I solve them by ode45. This clearly gives four column vectors representing each solution at each time in some time interval I provide.

How can I detect the first time (the value of t) in which, say, the following condition is fulfilled

X(:,1).^2+X(:,3).^2 > 0.99 && X(:,1).^2+X(:,3).^2 < 1

?

If it makes my question clearer, my equations represent the motion of a particle and my solutions return (x,v_x,y,v_y) and I'm looking for the time in which the particle first reaches a minimum radius of 0.99 but is still smaller than 1 (as if it enters a ring and I want to see when that happens).

Thanks in advance

Aucun commentaire:

Enregistrer un commentaire