Not enough input arguments
이전 댓글 표시
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
채택된 답변
추가 답변 (2개)
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
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.
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!