What does this error mean and how do I fix it?

1 Ansicht (letzte 30 Tage)
Aaron
Aaron am 20 Nov. 2013
Kommentiert: Walter Roberson am 20 Nov. 2013
I received the following error and am not sure how to correct it? I've copied my 3 function files below.
This thing is really beating me up!
>> project2
Error using feval
Undefined function 'eqns' for input arguments of type 'double'.
Error in fsolve (line 218)
fuser = feval(funfcn{3},x,varargin{:});
Error in project2 (line 42)
sol = fsolve(@eqns,[-100e-3 -80e-3]) % Solve for values of psid and psis
Caused by:
Failure in initial user-supplied objective function evaluation. FSOLVE
cannot continue.
Main Program:
function y = project2(pH,ckcl)
global Eo Ef N F R T c0 c10 c20 c30 c40 z z1 z2 z3 z4 ka kb L W h u
z = 1;
z1 = 1;
z2 = -1;
z3 = 1;
z4 = -1;
T = 300;
R = 8.314;
F = 96490;
Eo = 1;
Ef = 7.08e-10;
N = 1.3285e-5;
ka = 10^(-8+3);
kb = 10^(-2.5-3);
L = 4.5e-3;
W = 50e-6;
h = 200e-9;
u = 10e-3;
pH = 8;
Cckcl = logspace(0.1,500,100);
for i = 1:length(Cckcl)
ckcl = Cckcl(i)
if pH<= 7
c10 = 10^(-pH+3);
c20 = ckcl;
c30 = ckcl + 10^(-pH+3) - 10^(-(14-pH)+3);
c40 = 10^(-(14-pH)+3);
c0 = ckcl + 10^(-pH+3);
else
c10 = 10^(-pH+3);
c20 = ckcl + 10^(-pH+3) - 10^(-(14-pH)+3);
c30 = ckcl;
c40 = 10^(-(14-pH)+3);
c0 = ckcl + 10^(-(14-pH)+3);
end
kaba = sqrt((Eo*Ef*R*T)/(2*z^2*F^2*c0));
sol = fsolve(@eqns,[-100e-3 -80e-3]) % Solve for values of psid and psis
psis = sol(1);
psid = sol(2);
psid_ckcl(i) = psid;
I = quadl(@finite,0,h/2) % Solve for the integral of streaming current
G = (-W/u*L)*I;
G_ckcl(i) = G;
end
plot(ckcl,psid_ckcl) % Figure 1
plot(ckcl,G_ckcl) % Figure 2
First function program (eqns):
function y = eqns(psi)
global N F R T c10 c20 c30 c40 z z1 z2 z3 z4 ka kb Eo Ef L W h kaba Cs psi
Cs = 0.3;
Hs = c30*exp(-F*psi(1)/(R*T));
sigs = -F*N*(ka-kb*Hs^2)/(ka+Hs+kb*Hs^2);
sigd = sign(psi(2))*sqrt(2*Ef*R*T*((c10*(-1*exp(-(z1*F*psi(2))/(R*T))))+(c20*(-1*exp(-(z1*F*psi(2))/(R*T))))+(c30*(-1*exp(-(z1*F*psi(2))/(R*T))))+(c40*(-1*exp(-(z1*F*psi(2))/(R*T))))));
y(1) = Cs*(psid - psis) + sigs;
y(2) = -Cs*(psid - psis) - sigd;
Second function program (finite):
function y = finite(x)
global psid kaba h c10 c20 c30 c40 z1 z2 z3 z4 F R T
temp1 = 1+exp(x*-kaba) * tanh(F*psid/4*R*T);
temp2 = 1-exp(x*-kaba) * tanh(F*psid/4*R*T);
psi = 2*R*T/F * log(temp1./temp2);
pe = F*(z1*c10*exp(-z1*F/R*T*psi)+z2*c20*exp(-z2*F/R*T*psi)+z3*c30*exp(-z3*F/R*T*psi)+z4*c40*exp(-z4*F/R*T*psi));
y = pe.*(x.^2 - h*x);
end
  3 Kommentare
Aaron
Aaron am 20 Nov. 2013
It shows me the path:
>> which -all eqns
E:\Comp. Methods\Course Project 2\Project 2 revision\eqns.m
Walter Roberson
Walter Roberson am 20 Nov. 2013
At the command prompt, try
eqns(0)
and see if it can find eqns or not.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Fourier Analysis and Filtering finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by