solving simultaneous equations with fsolve

조회 수: 7 (최근 30일)
Mike
Mike 2012년 11월 3일
Hello,
I was given the code:
xo=1 ;
fun=@(X) [sum(X)-2; X(2).^2 -X(3)-5 ; X(1)+X(3.)^3-2];
x = fsolve(fun,xo)
But when I try to run it, I get the following error:
Index exceeds matrix dimensions.
Error in @(X)[sum(X)-2;X(2).^2,-X(3)-5;X(1)+X(3.)^3-2]
Error in fsolve (line 241) fuser = feval(funfcn{3},x,varargin{:});
Error in test2 (line 4) x = fsolve(fun,xo)
Caused by: Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue.
Can someone please explain why this isnt working?
Thanks!
Mike

채택된 답변

Matt J
Matt J 2012년 11월 3일
Your problem is 3-dimensional, but the initial guess you gave x0=1 is only 1-dimensional.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by