What's the problem that makes my MATLAB busy?

I am trying to graph 5 differential equations.
function dYfuncvecdt=ODEfunc(t, Yfuncvec)
L= Yfuncvec(1);
Cs= Yfuncvec(2);
Ci= Yfuncvec(3);
Rs= Yfuncvec(4);
Ri= Yfuncvec(5);
% Explicit equation
kf = 7.2e7;
kr = .34;
kt = .03;
ke = .165;
kdeg = .0022;
Vr = .013;
Nav = 6.02*10^23;
n = 10^9;
% Differential equations
dLdt = (-kf*L*Rs+kr*Cs)*(n/Nav);
dCsdt = kf*L*Rs-(kr+ke)*Cs;
dCidt = ke*Cs-kdeg*Ci;
dRsdt = -kf*L*Rs+kr*Cs+Vr-kt*Rs;
dRidt = kt*Rs-kdeg*Ri;
dYfuncvecdt=[dLdt;dCsdt;dCidt;dRsdt;dRidt];
I have no problem until here. This code works. But when i want to graph it by
clear
clc
close all
tspan = [0 60]; % Range for the time of the reaction
y0 = [0.1;0;0;5*10^(4);0]; % Initial values for the dependent variables
[t y]=ode45(@ODEfunc,tspan,y0);
plot(t,y(:,1),t,y(:,2),t,y(:,3),t,y(:,4),t,y(:,5));
legend('L','Cs','Ci','Rs','Ri')
xlabel('Time(min)')
ylabel('(M)')
It never graphs. MATLAB is busy. When I stop it by CTRL+C, i get the error
??? Operation terminated by user during ==> ode45 at 481

Answers (1)

You interrupted ode45, the function that solves your ODEs. This means MATLAB was still busy integrating your ODEs.
It can take a very long time to solve a problem if you use the wrong solver for your problem. My guess is that you are trying to solve a "stiff" problem, and that you should use an ODE solver specifically designed for "stiff" problems, such as ode15s.

Tags

Asked:

on 5 Dec 2013

Answered:

on 26 Dec 2013

Community Treasure Hunt

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

Start Hunting!