Not enough input arguments

4 ビュー (過去 30 日間)
Aman tiwari
Aman tiwari 2019 年 4 月 12 日
コメント済み: Star Strider 2019 年 4 月 12 日
Can you please help me in this error:
Not enough input arguments.
Error in eqs>eqs1 (line 46)
fcns(1) = F1- (r1*f1^2 + f1*(1-f1))/(r1*f1^2 + 2*f1*(1-f1) + r2*(1-f1)^2);
Error in fsolve (line 242)
fuser = feval(funfcn{3},x,varargin{:});
Error in eqs (line 41)
result = fsolve(@eqs1,guess)
Caused by:
Failure in initial objective function evaluation. FSOLVE cannot continue.
Program:
%global V F1in F2in Mw1 Mw2 Rho1 Rho2 Io f k11 r1 k22 r2 kt kd k12 k21 Vout TotalFin Pdot Residencetime
clc;
close all;
V = input('Please enter the vol of reactor (m3)');
F1in = input('Please enter the molar flow rate of Monomer_1 (mol/s)');
F2in = input(' Enter the molar flow rate of Monomer_2 (mol/s)');
Mw1 = input('Enter the molar mass of Monomer_1 (g/gmol)');
Mw2 = input(' Enter the molar mass of Monomer_2 (g/gmol)');
Rho1 = input('Enter the density of Monomer_1 (g/cm3)');
Rho2 = input('Enter the density of Monomer_2 (g/cm3)');
Io = input(' Enter the initial concentration of initiator (mol/m3)');
f = input(' Enter the initiator efficency');
k11 = input(' Enter the value of k11');
r1 = input('Enter the value of r1');
k22= input('Enter the value of k22');
r2 = input('Enter the value of r2');
kt= input('Enter the value of kt');
kd= input('Enter the value of kd');
k12 = k11/r1;
k21= k22/r2;
Vout = ( (F1in*Mw1)/Rho1 ) + ( (F2in*Mw2)/Rho2 );
TotalFin = F1in + F2in ;
Pdot = ( (f*kd*Io)/kt )^0.5;
Residencetime = V/Vout;
guess = [0.1 0.02];
result = fsolve(@eqs1,guess)
function fcns = eqs1(z,r1,r2,TotalFin,Residencetime,Pdot,k11,k22,k12,k21)
F1 = z(1);
f1 = z(2);
fcns(1) = F1- (r1*f1^2 + f1*(1-f1))/(r1*f1^2 + 2*f1*(1-f1) + r2*(1-f1)^2);
fcns(2) = TotalFin/(TotalFin - 31.71/(104-51*F1)) - ((Residencetime*Pdot)*(k11*k22*f1^2 + 2*k21*k12*f1 - 2*k21*k12*f1^2 + k22*k12 + k22*k12*f1^2 - 2*k22*k12*f1))/(k12*(1-f1) + k21*f1) -1 ;
end

採用された回答

Star Strider
Star Strider 2019 年 4 月 12 日
You need to pass all the arguments to ‘eqs1’ in your fsolve call.
Try this instead:
result = fsolve(@(z)eqs1(z,r1,r2,TotalFin,Residencetime,Pdot,k11,k22,k12,k21),guess)
  4 件のコメント
Aman tiwari
Aman tiwari 2019 年 4 月 12 日
Yes it worked.
Amazing.
.1769,0.1047,0.4843,53,104,.811,.903,20,.59,.176,.41---- values of input
But there is one issue my answer is F1 =0.2801 f1=0.0244
but i am getting
Solver stopped prematurely.
fsolve stopped because it exceeded the function evaluation limit,
options.MaxFunctionEvaluations = 200 (the default value).
result =
-28.2120 -0.0201
Star Strider
Star Strider 2019 年 4 月 12 日
I cannot use your ‘values of input’ because those are only 11 and 15 are required. Your ‘eqns1’ function only takes 9 parameters, so those lengths are also incompatible.
This should help with the 'MaxFunctionEvaluations' problem:
options = optimoptions('fsolve', 'MaxFunctionEvaluations',1000, 'MaxIterations',1000);
guess = [0.1 0.02];
result = fsolve(@(z)eqs1(z,r1,r2,TotalFin,Residencetime,Pdot,k11,k22,k12,k21),guess,options)
See the documentation on optimoptions (link) for details.

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

その他の回答 (1 件)

Stephen23
Stephen23 2019 年 4 月 12 日
編集済み: Stephen23 2019 年 4 月 12 日
You need to parameterize the objective function supplied to fsolve:
For example:
fun = @(z) eqs1(z,r1,r2,TotalFin,Residencetime,Pdot,k11,k22,k12,k21);
result = fsolve(fun,guess)
or use a nested function.
  1 件のコメント
Aman tiwari
Aman tiwari 2019 年 4 月 12 日
Thank you Stephen
But now saying too many arguments.
rror using eqs>eqs1
Too many input arguments.
Error in eqs>@(z)eqs1(z,r1,r2,TotalFin,Residencetime,Pdot,k11,k22,k12,k21)
Error in fsolve (line 242)
fuser = feval(funfcn{3},x,varargin{:});
Error in eqs (line 44)
result = fsolve(fun,guess)
Caused by:
Failure in initial objective function evaluation. FSOLVE cannot continue.

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

Community Treasure Hunt

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

Start Hunting!

Translated by