Not enough input arguments
2 views (last 30 days)
Show older comments
i have written the below script and code but when I run it it brings out "Not enough input arguments." error.
what could be the problem? FILES ATTACHED.
Script:
y0=[200;1];
tspan=[0, 360]; %days
[t,y]=ode45(@(t,y) SBR1,tspan,y0);
function:
%r=removal rate
%feeding: dcdt=(Q/(Vo+Qt))*(Co-C)-r
%reaction and withdrawal: dcdt=-r
function [C,S]=SBR1(~,y)
C=y(1);
S=y(2);
Qin=3.67; %m3/min
Qout=11; %m3/min
Sin=8; %influent DO conc
Cin=200; %g/L
nmax=1.44;
Kc=2.4;
Ko=0.594;
Vo=980; %m3
kLa=0.82; %h-1
SG=8;
ttotal=6*60;
tfeed=420/Qin; %feeding duration
treact=ttotal-tfeed; %reaction duration
taer=tfeed+15;
for t=0:tfeed
%feeding
C=(Qin/(Vo+Qin*tfeed))*(Cin-C)-(nmax*C/(Kc+C))*S/(Ko+S);
S=(Q/(Vo+Qin*tfeed))*(Sin-S)-(nmax*C/(Kc+C))*S/(Ko+S);
end
for t=tfeed:treact
%reaction settling and withdrawal
%aeration 15mins on 45mins off
C= -(nmax*C/(Kc+C))*S/(Ko+S);
for t=15:taer
S=kLa*(SG-S)-(nmax*C/(Kc+C))*S/(Ko+S);
tfeed=tfeed+45;
end
end
end
0 Comments
Accepted Answer
Neev
on 5 Jul 2023
Hi Kiprotich,
I reproduced your code on my system and found out that you had not initialised the output vector in the main code, so I corrected that. Along with that, in the cmd script for calling SBR1 file, you can miss the '[t y]' to get your desired output.
I am attaching updated versions of both SBR1.m and SBR.m along with this answer, you may run them on your system and verify.
I hope I was of help :)
More Answers (2)
Torsten
on 5 Jul 2023
Moved: Torsten
on 5 Jul 2023
You must return dCdt and dSdt at time t in function "SBR1":
function dy = SBR1(t,y)
C = y(1);
S = y(2);
...
% Calculate dCdt and dSdt
...
dy = [dCdt;dSdt];
end
I don't understand what you intend with the loops over t. The index t nowhere appears in the loops.
Steven Lord
on 5 Jul 2023
[t,y]=ode45(@(t,y) SBR1,tspan,y0);
The ode45 function will call the anonymous function with two inputs. That anonymous function will call the SBR1 function with no input arguments. Because SBR1 is being called with no input arguments:
function [C,S]=SBR1(~,y)
C=y(1);
when it reaches the line defining C there's no variable y in the SBR1 workspace and so that line throws an error.
You need to modify your anonymous function to pass the t and y variables that were passed into the anonymous function through to SBR1.
[t,y]=ode45(@(t,y) SBR1(t,y),tspan,y0);
Or since SBR1 doesn't use t, you could have SBR1 just accept y as input and update the anonymous function to match.
[t,y]=ode45(@(t,y) SBR1(y),tspan,y0);
function [C,S]=SBR1(y)
C=y(1);
% etc.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!