I always get the error I have written above. I decided to try a working code which you can find in the book Essentials of Chemical Reaction Engineering:International Edition(H.Scott Fogler). This code is also resembling the code that I wrote. And the error was the same when I copied it to my MatLab(7.12.0, R2011a)
Code:
function dYfuncvecdt = ODEfun(t,Yfuncvec);
Rs= Yfuncvec(1);
RTi= Yfuncvec(2);
Cs= Yfuncvec(3);
LTi= Yfuncvec(4);
% Explicit equations
kf = 7.2e7;
kr = .34;
keR = .03;
keC = .165;
krec = .058;
kdeg = .0022;
Vs = .013;
fR = .5;
fL = .5;
L = 10^-8;
Navgo = 6.02*10^23;
kfP = 0;
% Differential equations
dRsdt = -kf*Rs*L+kr*Cs-keC*Rs+(krec*(1-fR)*RTi)+Vs;
dRTidt = keR*Rs+keC*Cs-(krec*(1-fR)*RTi)-kdeg*fR*RTi;
dCsdt = kf*L*Rs-kr*Cs-keC*Cs;
dLTidt = keC*Cs+kfP*L*Navgo-(krec*(1-fL)*LTi)-kdeg*fR*RTi;
dYfuncvecdt=[dRsdt;dRTidt;dCsdt;dLTidt];
Error:
??? function dYfuncvecdt = ODEfun(t,Yfuncvec);
|
Error: Function definitions are not permitted in this context.