Failure in initial objective function evaluation. FSOLVE cannot continue
조회 수: 14 (최근 30일)
이전 댓글 표시
Hello, i'm trying to solve a nonlinear system of equations and I saw on the web that the function I should be looking for was "fsolve" (I am a beginner MATLAB user). I created my personal function as the following:
C=45.80;
H=5.88 ;
O=46.45 ;
N=1.20 ;
MH=1.008;
MC=12.01;
MO=16.00;
MN=14.01;
ER=0.4;
MC=0.3;
a=(H*MC)/(C*MH);
b=(O*MC)/(C*MO);
c=(N*MC)/(C*MN);
e=((24*MC)/(18*(1-MC)));
f= (ER *(1+(a/4)-(b/2)));
T=725;
lnT=log(T);
K1_m=((7082.848/T)+(-6.567*lnT)+(((7.466*10^-3)/2)*T)+(((-2.164*10^-6)/6)*(T^2))+((0.701*10^5)/(2*(T^2)))+32.541);
K2_wgs=((5870.53/T)+(1.86*lnT)+((-2.7*10^-4)*T)+(-58200/T^2)+(-18.007));
Heres the function am trying to solve
function F = root(x)
F(1) = ((x(3)^2)*k1_m) + x(1) + x(2) - 1;
F(2) = (x(2)*x(3))-((e+(0.5*a)-2)* x(1)* k2_wgs)-(x(1)*x(3)*k2_wgs)+(2*(x(1)^2)*k2_wgs)+(2*(x(1)*x(2))*k2_wgs);
F(3) = (2+(2*f)+b-(0.5*a))-(3*x(1))- (4*x(2))+ (x(3)) ;
end
Then i opened anotherfile to call fsolve
fun=@root;
x0=[1 1];
x= fsolve(fun, x0)
But something is wrong with my code and i get this command box report.
Error: File: root2d.m Line: 33 Column: 14
Function with duplicate name "root2d" cannot be defined.
Error in fsolve (line 242)
fuser = feval(funfcn{3},x,varargin{:});
Error in solved (line 3)
x= fsolve(fun, x0)
Caused by:
Failure in initial objective function evaluation. FSOLVE cannot continue.
댓글 수: 0
답변 (1개)
Alex Sha
2020년 4월 9일
You have three equations with three unknown parametrs, but initial start-values, you provide two only (x0=[1 1];), is this your problems?
참고 항목
카테고리
Help Center 및 File Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!