I'm trying to locate the locations of one of the equations in a system of differential equations in MATLAB.I'm trying to use the Events propety of odeset.How do I pick out the particular equation in my function?
options = odeset('Events',@event);
[t x tm xm ie] = ode45(@Lorenz,[0 200],I,options);
function X = Lorenz(t,x)
r = 15;
sigma = 10;
b = 8/3;
X(1,1) = sigma*(x(2,1)-x(1,1));
X(2,1) = r*(x(1,1)) - x(2,1) -x(1,1)*x(3,1);
X(3,1) = x(1,1)*x(2,1) - b*x(3,1);
end
function [value,isterminal,direction] = event(t,x)
value = Lorenz(t,x); %I can't specify X(3,1) here
isterminal = 0;
direction = -1;
end
In particular I'm trying to record whenever X(3,1) = 0.
Thank you
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…