Not Enough Input Arguments
4 次查看(过去 30 天)
显示 更早的评论
Hi, I am trying to solve this ODE problem, but I kept getting the "not enough input arguments" for the FT line. What is the mistake that I made?Here's my code:
function dFdV = etOH_prod(V,F)
dFdV = zeros(4,1);
% A = C2H4
% B = H2O
% C = C2H5OH
% D = (C2H5)2O
% F(1) = FA;
% F(2) = FB;
% F(3) = FC;
% F(4) = FD;
CTO = 0.9570;
kf1 = 4981.8737; % forward rate_1
kr1 = 1623976.823; % reverse rate_1
k2 = 3792.6052; % forward rate_2
FT = F(1) + F(2) + F(3) + F(4);
CA = CTO*( F(1)/FT );
CB = CTO*( F(2)/FT );
CC = CTO*( F(3)/FT );
r1A = -kf1*CA*CB + kr1*CC;
r2C = -k2*CC;
r1B = r1A;
r1C = -r1A;
r2B = (-1/2)*r2C;
r2D = (-1/2)*r2C;
rA = r1A;
rB = r1B + r2B;
rC = r1C + r2C;
rD = r2D;
dFdV(1,:) = rA;
dFdV(2,:) = rB;
dFdV(3,:) = rC;
dFdV(4,:) = rD;
end
0 个评论
回答(2 个)
Walter Roberson
2024-6-23
You tried to run the function by pressing the green Run button. Pressing the Run button has the effect of running the code without any input parameters.
MATLAB never searches the environment looking for variables with the same name as named parameters for a function. If you do not pass in values in positions corresponding to named parameters, then MATLAB always treats the named parameters as missing.
0 个评论
Sam Chak
2024-6-23
There is no error in my simulation below:
[V, F] = ode45(@etOH_prod, [0 10], ones(4, 1));
plot(V, F), grid on, xlabel('V'), ylabel('F')
function dFdV = etOH_prod(V,F)
dFdV = zeros(4,1);
% A = C2H4
% B = H2O
% C = C2H5OH
% D = (C2H5)2O
% F(1) = FA;
% F(2) = FB;
% F(3) = FC;
% F(4) = FD;
CTO = 0.9570;
kf1 = 4981.8737; % forward rate_1
kr1 = 1623976.823; % reverse rate_1
k2 = 3792.6052; % forward rate_2
FT = F(1) + F(2) + F(3) + F(4);
CA = CTO*( F(1)/FT );
CB = CTO*( F(2)/FT );
CC = CTO*( F(3)/FT );
r1A = -kf1*CA*CB + kr1*CC;
r2C = -k2*CC;
r1B = r1A;
r1C = -r1A;
r2B = (-1/2)*r2C;
r2D = (-1/2)*r2C;
rA = r1A;
rB = r1B + r2B;
rC = r1C + r2C;
rD = r2D;
dFdV(1,:) = rA;
dFdV(2,:) = rB;
dFdV(3,:) = rC;
dFdV(4,:) = rD;
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!