ODE 24 "not enough input arguments"

I am having some difficulty using ODE45 utilizing a system of differential equation. Below is my code which produces the error "not enough input arguments" for line 9; which defines the variable "ra". I am confused on what this error code means. my original script utilizes a set of 4 initial condition for C(1) C(2) C(3) and C(4) and a defined time span of [0 500]. Thank you for the help in advance; any input on what this code will be appreciated.
function conversion=ODEFUNCTION611b(t,C)
V0=200; %dm^3
Kc=1.08; %given equilibirum constant
k=9*10^-5;%dm^3/mol*s rate constant
v=0.05; %dm^3/s
Cb0=10.93; %mol/dm^3
%Ca0=7.72 %mol/dm^3
ra=-k*((C(1)*C(2))-((C(3)*C(4))/Kc))
V=V0+v*t
dCadt=ra-(v/V)*C(1)
dCbdt=ra+((v*(Cb0-C(2)))/V)
dCcdt=-ra-((v*C(3))/V)
dCddt=-ra-((v*C(4))/V)
eqns=[dCadt dCbdt dCcdt dCddt]
conversion=eqns
end

 採用された回答

Star Strider
Star Strider 2020 年 3 月 24 日

0 投票

This runs without error (R2020a):
function conversion=ODEFUNCTION611b(t,C)
V0=200; %dm^3
Kc=1.08; %given equilibirum constant
k=9*10^-5;%dm^3/mol*s rate constant
v=0.05; %dm^3/s
Cb0=10.93; %mol/dm^3
%Ca0=7.72 %mol/dm^3
ra=-k*((C(1)*C(2))-((C(3)*C(4))/Kc));
V=V0+v*t;
dCadt=ra-(v/V)*C(1);
dCbdt=ra+((v*(Cb0-C(2)))/V);
dCcdt=-ra-((v*C(3))/V);
dCddt=-ra-((v*C(4))/V);
eqns=[dCadt dCbdt dCcdt dCddt];
conversion=eqns(:);
end
with:
ic = zeros(4,1)+1;
ts = [0 500];
[T,C] = ode45(@ODEFUNCTION611b, ts, ic);
figure
semilogy(T,C)
grid
Make appropriate changes to get the result you want.

4 件のコメント

TL
TL 2020 年 3 月 25 日
Even utilizing your input for the initial conditions and timepsan I am still recieving the "not enough inputs" error message for my defined "ra". I am utilizing R2019a so will look into potential differences between versions. Thank you for the help.
Star Strider
Star Strider 2020 年 3 月 25 日
I have no idea what the problem could be, since ‘ra’ is defined in the function. It is not an input to anything.
I corrected some errors in your ‘ODEFUNCTION611b’ function so that it is compatible with what ode45 expects, and posted it in my Answer.
Did you use my corrected version?
TL
TL 2020 年 3 月 25 日
I found the problem I had used your corrected version; but incorrectly inputed my initial conditions based on your corrected version. I found the error and have corrected it. Thank you for the help.
Star Strider
Star Strider 2020 年 3 月 25 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

質問済み:

TL
2020 年 3 月 24 日

コメント済み:

2020 年 3 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by