How I can check the system solution with a Matlab ODE function.

1 次查看(过去 30 天)
dydt(1) = 1.3*(y(3) - y(1)) + 10400*exp(20.7 - 1500/y(1))*y(2);
dydt(2) = 1880 * (y(4) - y(2) * (1+exp(20.7 - 1500/y(1))));
dydt(3) = 1752 - 269*y(3) + 267*y(1);
dydt(4) = 0.1 + 320*y(2) - 321*y(4)
y(t0)= [50,0,600,1]

采纳的回答

Jan
Jan 2018-6-11
function main
t0 = 0;
y0= [50,0,600,1]
[t,y] = ode45(@fcn, [t0, 7], y0);
plot(t, y);
end
function dydt = fcn(t, y)
dydt = zeros(4,1);
dydt(1) = 1.3*(y(3) - y(1)) + 10400*exp(20.7 - 1500/y(1))*y(2);
dydt(2) = 1880 * (y(4) - y(2) * (1+exp(20.7 - 1500/y(1))));
dydt(3) = 1752 - 269*y(3) + 267*y(1);
dydt(4) = 0.1 + 320*y(2) - 321*y(4);
end
  3 个评论
Jan
Jan 2018-6-11
I guessed the endpoint 7. This takes a long time, in fact. If you use 2, ODE45 can solve this in seconds. ODE45 is designed to integrate non-stiff ODEs. If your system is stiff, use e.g. ode23s.
tic
[t,y] = ode23s(@fcn, [t0, 7], y0);
toc
% Elapsed time is 0.045184 seconds.
Camilo Sánchez
Camilo Sánchez 2018-6-11
Thank for your answer. I already assumed it was something like that and I used ODE15S. Thanks for your support.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by