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
2018-4-7
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
2018-4-7
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 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!