Recieving error Index exceeds the number of array elements (1) when attempting to useODE45?
Show older comments
I am trying to produce a solution to a pair of ODE's that model a CSTR. When the function is run it gives the error Index exceeds the number of array elements (1). I have attempted to change the array dimensions to allow for the undex but have not been succesful.
function dt=tutorial3(y,t)
F=1;
DH=-5960;
pCp=500;
UA=150;
V=1;
Ti=298;
Tj=298;
k0=9703*3600;
Cai=1;
R=1.987;
E=11843;
dt=zeros(2,1);
dt(1)=((F*Cai)-(F*y(1))-(k0*exp(-E/(R*y(2))))*V)/V;
dt(2)=F*pCp*(Ti-y(2))+(-DH)*(k0*exp(-E/(R*y(2))))*V-UA*(y(2)-Tj);
end
tspan=[0 100];
y0=[5;350];
[t,y]=ode45(@tutorial3,tspan,y0);
plot(t,y)
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!