Not enough input arguments
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Neev
2023-7-5
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 :)
更多回答(2 个)
Steven Lord
2023-7-5
[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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!