필터 지우기
필터 지우기

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개)

Matt J
Matt J 2020년 10월 13일
  댓글 수: 1
J. Alex Lee
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!

Translated by