FEVAL ERROR! FLASH CALCULATIONS
2 views (last 30 days)
Show older comments
I KEEP GETTING THIS ERROR. I DONT KNOW WHY.
Error using ==> feval
_Undefined function or method 'dewpoint4' for input arguments of type 'double'.
Error in ==> fsolve at 254
fuser = feval(funfcn{3},x,varargin{:});
Caused by:
Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue.
THIS IS MY FUNCTION
function g = dewpoint4(u);
% This function is to be used with fsolve to find the dew point of a
% mixture that is 30% ethanol, 30% methanol, 40% water at 2 atm.
% Data
y(1) = 0.2;%mole fraction ethylalcohol
y(2) = 0.8;%mole fraction ethylacetate
P = 760;%pressure in mmHg
A = [7.09808 8.04494];
B = [1238.71 1554.3];
C = [217 222.65];
a(1,2) = 0.331; %ethylacetate
a(2,1)=0.3972;%ethylalcohol
%Define the unknowns
T = u(1);
x = u(2:3);
%calculate pure component vapor pressure
logp = A-B./(T+C);
pvap = 10.^(logp);
%calculate activity coefficients
gamma(1) = 10.^(a(1,2)./(1+x(1).*a(1,2))./(x(2).*a(2,1)).^2;
gamma(2) = 10.^(a(2,1)./(1+x(2).*a(2,1))./(x(1).*a(1,2)).^2;
%calculate equilibrium constants
K = gamma.*pvap./P;
%Equilibrium Equations
g(1:2) = K.*x-y;
%Summation Equation
g(3) = 1-sum(x);
(DOING FLASH CALCS)
0 Comments
Answers (1)
Walter Roberson
on 18 Sep 2011
MATLAB cannot find dewpoint4 at all -- it cannot find the code you show above.
Did you save the above code in dewpoint4.m in a directory that is in your matlab path ?
Alternately, is it stored in the same file as the function (not script!) that calls fsolve() ? If so then did you call fsolve() with 'dewpoint4' (in quotes) as the argument, or did call fsolve with @dewpoint4 (@ and no quotes) as the argument? If you had both routines in the same file and you used the quoted version then MATLAB will not be able to find the function; using @dewpoint4 is better.
0 Comments
See Also
Categories
Find more on Thermal Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!