solving differential equation system with ode45
조회 수: 3 (최근 30일)
이전 댓글 표시
I have a system of second order diferential equations:

I would like to solve this system using ode45.
here is what i tried for solving the system:
function dYdt = odefcn(t,Y)
load STIFF_VALUES
load THETA
A=6.58e5;B=1.8;C_1=0.3083e-3;C_2=0.4439e-3;D=6.58e5;E=1.8;F=60e3;
G=51.6831;H=0.96e-1;I=F*30/25;J=70.4769;K=2e-1;M=67e-3;
L = interp1(THETA,STIFF_VALUES,t);
N=L*((Y(1)-Y(3))-(G*Y(5)-J*Y(7)))+M*((Y(2)-Y(4))-...
(G*Y(6)-J*Y(8)));
dYdt = [ Y(2);
1/C_1*(A*Y(1)+ B*Y(2)-N);
Y(4);
1/C_2*(-D*Y(3)- E*Y(4)+N);
Y(6);
1/H*(F+G*N);
Y(8);
1/K*(-I-J*N)];
end
init_cond = [0,0,0,0,0,2400,0,2000]';
t_interval=[0 10];
[t,y]=ode45(@(t,Y) odefcn(t,Y) , t_interval , init_cond);
I got NaN values for y(:,1).
*I tried "ode15s" which returns the following warning!
Warning: Failure at t=1.451171e-02. Unable to meet integration tolerances without reducing the
step size below the smallest value allowed (2.775558e-17) at time t.
댓글 수: 1
Torsten
2022년 9월 17일
The setup of the system for ODE45 looks correct.
So it remains to check the initial conditions and the model parameters.
You should load THETA and STIFF_VALUES in the program where you call ode45 and pass the arrays to the solver as
[t,y]=ode45(@(t,Y) odefcn(t,Y,THETA,STIFF_VALUES) , t_interval , init_cond);
...
function dYdt = odefcn(t,Y,THETA,STIFF_VALUES)
...
end
This saves time.
Further, take care that THETA(1) <= t <= THETA(end). Otherwise, interp1 will return NaN for L.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!