Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
how to fix a value in a function during an ode integration, that does not change during the integration
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
hi all,
I have to fix a value during an ode integration:
if z > 1000
dx = v*cos(gamma)*cos(chi);
dy = v*cos(gamma)*sin(chi);
dz = v*sin(gamma);
elseif z <= 1000
x_scalato = 22991;
xD = x_scalato + 1e3 * [0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5];
AD = [-50 -45 -35 -20 -10 5 20 30 40 50 50];
BD = [0 -5 -25 -45 -50 -50 -50 -30 -5 0 0];
lambda = 0.1;
h_star = 1000;
A_ws = interp1(xD,AD,x,'spline');
B_ws = interp1(xD,BD,x,'spline');
Wx = lambda * A_ws;
Wy = lambda * A_ws;
Wh = lambda * z/h_star * B_ws;
dx = v*cos(gamma)*cos(chi) + Wx;
dy = v*cos(gamma)*sin(chi) + Wy;
dz = v*sin(gamma) + Wh;
end
in ode function I have this if cycle where in the elseif statement there is an interpolation
I have to remove the hard code value
x_scalato = 22991;
x_scalato is the value of x as soon as z is less then 1000, so when there is the elseif statement.
this value is computed during the FIRST cycle of integration and remain constant, so for all the remain part of integration remain the same.
Can you help me to do this ?
Many thank for your time and consideration
1 comentario
Respuestas (1)
Matt J
el 13 de Oct. de 2020
A relevant doc page:
1 comentario
J. Alex Lee
el 13 de Oct. de 2020
i believe the issue is that the value must be generated during an early stage of the integration.
But to your point, a valid strategy may be to split the integration into 2 steps, one of them up to the event, at which time the value of interest can be extracted as an output, and then passed as an extra argument to the second separate integration.
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!