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)

Answers (1)

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 Comments

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".)
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.

Sign in to comment.

Categories

Asked:

on 7 Apr 2018

Commented:

on 7 Apr 2018

Community Treasure Hunt

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

Start Hunting!