problem while Solving nonlinear system
Show older comments
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)
Star Strider
on 7 Apr 2018
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
marten marten
on 7 Apr 2018
Star Strider
on 7 Apr 2018
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.
Categories
Find more on Systems of Nonlinear Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!