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]
0 个评论
采纳的回答
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
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.
更多回答(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!