フィルターのクリア

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 Center および File ExchangeProgramming についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by