ODE solver running continuously. Why?
Show older comments
I cannot figure out why my code (to solve for a system of ODE's) is running continuously. Every time I run it, I have to use CTRL+C to stop it. Please help! The code is:
clear
clc
%Error in ODE solver, will not "stop" solving.
fprintf('\nQuestion 3\n');
tspan= [0:.05:20];
F0=[2.5; 3; -1; 1];
[t,fn]=ode45(@fn_feq3,tspan,F0);
y=fn(:,1);
x=fn(:,2);
plot(t,x,t,y);
xlabel('Time (sec)');
ylabel('x and y');
legend('x vs t','y vs t');
title('#3 Plot');
function dF=fn_feq3(t,f)
dy=f(1);
dx=f(2);
dz=(2*f(2))+(-6*f(1))+(-3*f(1)*f(3));
dw=14-2*f(4)-2*f(2)*f(1);
dF=[dy;dx;dz;dw];
end
Accepted Answer
More Answers (0)
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!