How I can check the system solution with a Matlab ODE function.
1 view (last 30 days)
Show older comments
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 Comments
Accepted Answer
Jan
on 11 Jun 2018
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 Comments
Jan
on 11 Jun 2018
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.
More Answers (0)
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!