How to fix error in fsolve

8 Ansichten (letzte 30 Tage)
Sujyot Suratran
Sujyot Suratran am 12 Jan. 2021
Kommentiert: Alan Stevens am 13 Jan. 2021
I want to solve following function
function F = root2d(x)
F(1) = X(1) - exp(13.5-(2700/(x(3)-55)));
F(2) = x(2) - exp(14-(3050/(x(3)-57)));
F(3) = 0.4*x(1) - 140*x(2);
F(4) = 0.6*x(2) - 140*x(5);
F(5) = x(4) + x(5)-1;
And I am getting following error
Error in root2d (line 3)
F(1) = X(1) - exp(13.5-(2700/(x(3)-55)));
Error in fsolve (line 258)
fuser = feval(funfcn{3},x,varargin{:});

Antworten (1)

Alan Stevens
Alan Stevens am 12 Jan. 2021
Is it just a case of changing
F(1) = X(1) - exp(13.5-(2700/(x(3)-55)));
to
F(1) = x(1) - exp(13.5-(2700/(x(3)-55)));
  2 Kommentare
Sujyot Suratran
Sujyot Suratran am 13 Jan. 2021
Thank you but Even after correcting the case,
and using following function
fun = @root2d;
x0 = [0,0];
x = fsolve(fun,x0)
I am getting following error
Index exceeds the number of array elements (2).
Error in root2d (line 2)
F(1) = x(1) - exp(13.5-(2700/(x(3)-55)));
Error in fsolve (line 258)
fuser = feval(funfcn{3},x,varargin{:});
Caused by:
Failure in initial objective function evaluation. FSOLVE cannot continue.
Alan Stevens
Alan Stevens am 13 Jan. 2021
Your F expressions contain x(1) to x(5), but you only pass two values, [0, 0] to the function.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Systems of Nonlinear Equations finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by