Not enough input arguments
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (1)
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 commentaire
Aman tiwari
le 12 Avr 2019
Catégories
En savoir plus sur Random Number Generation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!