Getting the data from events in ode 113
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I created the following events function to terminate the integration at dot product sign change
function [value,isterminal,direction] = terminator(t,yy)
jed = mjd20002jed(t);
ncent = 12;
kmflag = 0;
inc = deg2rad(23+26/60+21.448/3600);
[rr, vv] = body(jed, 3, ncent, kmflag);
rrE = equ2ecl(rr, inc);
vvE = equ2ecl(vv, inc);
A = yy(1) - rrE(1);
B = yy(2) - rrE(2);
C = yy(3) - rrE(3);
D = yy(4) - vvE(1);
E = yy(5) - vvE(2);
F = yy(6) - vvE(3);
T_1 = [A, B, C];
T_2 = [D, E, F];
d_term = dot(T_1, T_2);
value = [d_term];
isterminal = 1;
direction = 1;
end
However now I want to use the first value of yy(4:6) that enters in the event function to be used instead of the current value. Is there any way to capture that inside a variable. I tried looping but since the program executes completely the counter resets everytime. Any ideas how to proceed
2 comentarios
Bruno Pop-Stefanov
el 6 de Oct. de 2014
What do you mean by using the first value that enters the function? Could you describe a bit more what the counter you are mentioning is?
I am not sure what you would like to do but you can use persistent variables to capture a state between several executions of a function:
Respuestas (0)
Ver también
Categorías
Más información sobre Ordinary Differential Equations en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!