Info
この質問は閉じられています。 編集または回答するには再度開いてください。
how to fix a value in a function during an ode integration, that does not change during the integration
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Matt J
2020 年 10 月 13 日
A relevant doc page:
1 件のコメント
J. Alex Lee
2020 年 10 月 13 日
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.
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!