Getting the data from events in ode 113

1 Ansicht (letzte 30 Tage)
Divas am 3 Okt. 2014
Bearbeitet: Divas am 7 Okt. 2014
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;
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 Kommentare
Divas am 7 Okt. 2014
Bearbeitet: Divas am 7 Okt. 2014
The input variable for this integration starts from variables from previous integration which I terminated at some given condition.
This value enters first in 'yy' when the events function is called from the second integration, and I want to use that to compute the difference between that value and the values that are being generated following the integration.
If I use a variable to store that data, it gets overwritten with each call of events function. Although I'll give it a try using persistent variable
Persistent does the job. Thanks a lot.

Melden Sie sich an, um zu kommentieren.

Antworten (0)


Mehr zu Programming finden Sie in Help Center und File Exchange


Community Treasure Hunt

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

Start Hunting!

Translated by