필터 지우기
필터 지우기

Not enough input arguments

조회 수: 1 (최근 30일)
KIPROTICH KOSGEY
KIPROTICH KOSGEY 2023년 7월 5일
답변: Steven Lord 2023년 7월 5일
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

채택된 답변

Neev
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 :)
  댓글 수: 1
KIPROTICH KOSGEY
KIPROTICH KOSGEY 2023년 7월 5일
Thank you Neev, Be blessed!

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Torsten
Torsten 2023년 7월 5일
이동: Torsten 2023년 7월 5일
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.
  댓글 수: 1
KIPROTICH KOSGEY
KIPROTICH KOSGEY 2023년 7월 5일
Thank you Torsten.
I am trying to sequence a series of reactions over some 360 minute duration with minicycles in between. I bet I still have to further improve it.

댓글을 달려면 로그인하십시오.


Steven Lord
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.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by