Ode45 - Too many input arguments.

3 views (last 30 days)
Otavio
Otavio on 18 Aug 2014
Answered: Star Strider on 18 Aug 2014
Hello, I am trying to run an ode45, but I get the error:
Error using VanDerVusse_process>@(t,x)massbalanceA(t) Too many input arguments.
The code is:
[t,x]=ode45(@(t,x) massbalanceA(t,x,Cai,Fin,Tin,Qk,tin),tin,Ca,Cb,T,Tk);
The function massbalanceA is:
function[dx]=massbalanceA(t,x,Cai,Fin,Tin,Qk,tin)
global E1 E2 E3 k10 k20 k30 kw Cp Cpk deltaH1 deltaH2 deltaH3 dens mk Ar Vr
Ca=x(1);
Cb=x(2);
T=x(3);
Tk=x(4);
Fin=interp1(tin,Fin,t);
Cai=interp1(tin,Cai,t);
Tin=interp1(tin,Tin,t);
Qk=interp1(tin,Qk,t);
k1=k10*exp(E1/T);
k2=k20*exp(E2/T);
k3=k30*exp(E3/T);
dCa=Fin./Vr.*(Cai-Ca)-k1.*Ca-k3.*Ca.^2;
dCb=-Fin./Vr.*Cb+k1.*Ca-k2.*Cb;
dT=Fin./Vr.*(Tin-T)+kw.*Ar./(dens.*Cp.*Vr).*(Tk-T)-1/(dens.*Cp).*(k1.*Ca.*deltaH1+k2.*Cb.*deltaH2+k3.*Ca.^2.*deltaH3);
dTk=Qk./(mk.*Cpk)+kw.*Ar/(mk.*Cpk).*(T-Tk);
dx=[dCa;dCb;dT;dTk];
end
Thank you for your attention.

Answers (1)

Star Strider
Star Strider on 18 Aug 2014
I doubt the problem is with massbalance. The ode45 function takes at most four arguments, your function (that you refer to correctly), then a two or more element time vector (tspan), a vector of your initial conditions (a (4x1) vector here), and an options structure if you want to change the default options for ode45. You gave ode45 six arguments, only the first of which (your ODE function call) looks correct.

Tags

Community Treasure Hunt

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

Start Hunting!