problem while Solving nonlinear system

Hi I am trying to Solve this nonlinear system but it is showing me this error * * (Not enough input arguments. Error in (line 4) F(1) = 3 x(1)- cos(x(2).*x(3)) - 0.5 ; )***
function F = root3d(x)
F(1) = 3* x(1)- cos(x(2).*x(3)) - 0.5 ; F(2) = x(1).^2-81 .*(x(2)+0.1).^2 + sinx(3) + 1.06; F(3) = exp(-x(1)) * (x(2)) + 20*x(3)+ 9.471 fun = @root2d; x0 = [0,0]; x = fsolve(fun,x0,options)

답변 (1개)

Star Strider
Star Strider 2018년 4월 7일

0 개 추천

This corrected code works for me:
function F = root3d(x)
F(1) = 3* x(1)- cos(x(2).*x(3)) - 0.5 ;
F(2) = x(1).^2-81 .*(x(2)+0.1).^2 + sin(x(3)) + 1.06;
F(3) = exp(-x(1)) * (x(2)) + 20*x(3)+ 9.471
end
fun = @root3d;
x0 = [0,0,0];
x = fsolve(fun,x0);
x =
499.9997e-003 2.6729e-003 -473.6311e-003
You did not include an optimoptions call, so I did not include an ‘options’ structure as a argument to fsolve.

댓글 수: 2

marten marten
marten marten 2018년 4월 7일
i used your code and it is showing this error
Untitled2 Error: File: Untitled2.m Line: 6 Column: 1 This statement is not inside any function. (It follows the END that terminates the definition of the function "root3d".)
Star Strider
Star Strider 2018년 4월 7일
It will work most easily if you save your ‘root3d’ function to its own function file in your MATLAB search path as root3d.m.
If you are not familiar with the MATLAB search path, see the documentation on What Is the MATLAB Search Path? (link) for a full discussion.
There are other ways to work with it as well. See the documentation on Function Basics (link) for details.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기

질문:

2018년 4월 7일

댓글:

2018년 4월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by