Error using ode15s - Not enough input arguments.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hi I'm trying to solve this system of ODEs but when I run it I have different errors. Have you any idea?
function [dxdt] = f_ASM( t,x,parameters )
%parameters iNBM=parameters(1); iNXI=parameters(2); iNSS=parameters(3); fXi=parameters(4); bAOBNO2=parameters(5); bAOBO2=parameters(6); bHNOx =parameters(7); bHO2 =parameters(8); bHSTOO2=parameters(9); bNOBNO3=parameters(10); bNOBO2 =parameters(11); cPH =parameters(12); KAOBFA =parameters(13); KAOBFNA =parameters(14); KAOBNH4=parameters(15); KAOBNO2=parameters(16); KAOBNO3=parameters(17); KAOBO2=parameters(18); KAOBPH=parameters(19); KHA =parameters(20); KHNH4 =parameters(21); KHNO2=parameters(22); KHNO3=parameters(23); KHO2=parameters(24); KHPH=parameters(25); kHSTO=parameters(26); KHSTO=parameters(27); KNOBFA =parameters(28); KNOBFNA =parameters(29); KNOBNO2 =parameters(30); KNOBNO3=parameters(31); KNOBO2=parameters(32); KNOBPH=parameters(33); mumaxAOB=parameters(34); mumaxH=parameters(35); mumaxNOB=parameters(36); niSTONOx =parameters(37); niHNOx=parameters(38); YAOB=parameters(39); YHNOx =parameters(40); YHO2=parameters(41); YHSTONOx=parameters(42); YHSTOO2=parameters(43); YNOB =parameters(44);
%identify states (THE ORDER IS THE SAME AS DEFINED IN XINITIAL) XAOB=x(1); XNOB=x(2); XH=x(3); XSTO=x(4); NO2=x(5); NO3=x(6); K_NH4=x(7); SA=x(8);
%Calculate derivatives. are function of signals (pH and dissolved oxygen) dxAOBdt = .....; dxNOBdt = .....; dxHdt = .......; dxXSTOdt=......; dxNO2dt=.......; dxNO3dt=.......; dxNH4dt=.......; dxSAdt=........; %Merge all the differentials together in vector dxdt dxdt=[dxAOBdt dxNOBdt dxHdt dxXSTOdt dxNO2dt dxNO3dt dxNH4dt dxSAdt]; x = [iniXAOB iniXNOB iniXH iniXSTO iniNO2 iniNO3 iniNH4 iniSA ]; parameters=[iNBM iNXI iNSS fXi bAOBNO2 bAOBO2 bHNOx bHO2 bHSTOO2 bNOBNO3 bNOBO2 cPH KAOBFA KAOBFNA KAOBNH4 KAOBNO2 KAOBNO3 KAOBO2 KAOBPH KHA KHNH4 KHNO2 KHNO3 KHO2 KHPH kHSTO KHSTO KNOBFA KNOBFNA KNOBNO2 KNOBNO3 KNOBO2 KNOBPH mumaxAOB mumaxH mumaxNOB niSTONOx niHNOx YAOB YHNOx YHO2 YHSTONOx YHSTOO2 YNOB ]; tEnd = max(t); vTime =linspace(0,tEnd); %solution [tOut,xSolution] = ode15s(@f_ASM,vTime,x,parameters);
the reported errors are:
>> SBR Error using f_ASM (line 5) Not enough input arguments.
Error in odearguments (line 87) f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode15s (line 148) [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in SBR (line 98) [tOut,xSolution] = ode15s(@f_ASM,vTime,x,parameters);
>> Thanks!!!
0 comentarios
Respuestas (1)
Ced
el 16 de Mzo. de 2016
Editada: Ced
el 16 de Mzo. de 2016
Hi
ode15s, like all Matlab ode functions, requires the function to be of the form y' = f(t,y). Your function f_ASM has 3 parameters! Also, ode15s does not know what to do with that last argument "parameters" you passed.
A common way of dealing with this is to define an anonymous function. In your case, I believe that would be
[tOut,xSolution] = ode15s(@(t,x)f_ASM(t,x,parameters),vTime,x);
Cheers
0 comentarios
Ver también
Categorías
Más información sobre Ordinary Differential Equations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!