"Non enough input arguments" to solve non linear equations
1 view (last 30 days)
Show older comments
function sg = syngas(X)
%
%Definición de incógnitas
%
F = X(1);
Xco = X(2);
Xco2 = X(3);
Xh2 = X(4);
Xch4 = X(5);
Xh2o = X(6);
Xn2 = X (7);
W = X(8);
S = X(9);
A = X(10);
%Datos conocidos
H = 0.07;
AF = 2.76; %kg air/kg fuel
%T = 1000; % temperatura en K
P = 1; % presión en atm
G = 1; %
SF = 0.117; %kg steam/kg fuel
Kpw = 2.617; % constante
Kpb = 1.9; % constante
% Fracciones molares
Yc = 0.83;
Yh = 0.09;
Yo = 0.07;
% Pesos moleculares de los compuestos
MWc = 12;
MWh = 1;
MWh20 = 18;
MWo = 16;
MWo2 = 32;
MWn = 14;
%
%Las ecuaciones
%
% 1.- CARBON solves for Xch4
s1 = ((Yc*F)/MWc)*(22.4/G)-Xco-Xco2-Xch4;
% 2.- HIDRÓGENO solves for h20
s2 = ((22.4/G)*((F*Yh)/MWh)+(2/MWh20)*(W+S)-2*Xh2-4*Xch4)*0.5-Xh2o;
% 3.- OXÍGENO solves for co
s3 = ((Yo*F)/MWo)+(W+S/MWh20)+((0.23*A)/MWo2)*2*(22.4/G)-2*Xco2-Xh2-Xco;
% 4.- NITRÓGENO solves for F
s4 = ((G/22.4)*(2*Xn2)-(2*(0.77*A)/MWn2)*(MWn/Yn))-F;
% 5.- fracciones másicas de compuestos, solves for N2
s5 = 1-Xco-Xco2-Xh2-Xch4-Xh2o-Xn2;
% 6.- constante Kpw, solves for h2
s6 = ((Xh2o*Kpw)/(Xco*P))-Xh2;
% 7.- constante Kpb, solves for co2
s7 = ((Xco^2*P)/Kpb)-Xco2;
% 8.- agua
s8 = (F *(H/(1-H)))-W;
% 9.- steam
s9 = (F*SF)-S;
%10.- air
s10 = (F*AF)-A;
%Vector solución
sg = [s1; s2; s3; s4; s5; s6; s7; s8; s9; s10];
This is my code: 10 unknows and 10 equations.
And then in another file i have a script that calls for fsolve
% syngas script
% initial guess
F0 = 1;
Xco0 = 0.0001; Xco20 = 0.0001; Xh20 = 0.0001;
Xch40 = 0.0001; Xh2o0 = 0.0001; Xn20 = 0.0001;
W0 = 1; S0 = 1; A0 = 1;
% pack up initial guess
X0 = [F0; Xco0; Xco20; Xh20; Xch40; Xh2o0; Xn20; W0; S0; A0];
% call fsolve
%
fhandle = @syngas;
X = fsolve(fhandle,X0);
% Display answers
%
disp('F0, Xco, Xco2')
disp(X(1:3))
disp('Xh2, Xch4, Xh2o,Xn2')
disp(X(4:7))
disp('W,S,A')
disp(X(8:10))
And this is the error i get:
>> syngas
Not enough input arguments.
Error in syngas (line 6)
F = X(1);
>>
i'm not sure what it means. Any advice? thank you!!
2 Comments
Walter Roberson
on 22 Mar 2020
Do not give the name of the function at the command line, give the name of the script.
Accepted Answer
More Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!