Not Enough Input Arguments
조회 수: 21 (최근 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일 4:30
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일 3: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!