Index exceeds matrix dimensions using fsolve

I am writing this simple matlab code and it is not running at all
function F = position4(x)
F(1) = 40*cos(50* (pi/180)) + 100* cos(x(2)* (pi/180)) - x(1) ;
F(2) = 40*sin(50* (pi/180)) + 100 * sin(x(2)* (pi/180));
guess = [120, 17];
fsolve(@position4,guess )
end

1 Comment

Please post the inputs, how you call it and a copy of the complete error message. Otherwise trying to help you require too much guessing, what the problem is. It is strange, that you call fsolve from within the function you provide as handle.

Sign in to comment.

 Accepted Answer

function main
guess = [120, 17];
xsol = fsolve(@position4,guess )
function F = position4(x)
F(1) = 40*cos(50* (pi/180)) + 100* cos(x(2)* (pi/180)) - x(1) ;
F(2) = 40*sin(50* (pi/180)) + 100 * sin(x(2)* (pi/180));
... and run this as a function file named "main.m"
Best wishes
Torsten.

1 Comment

Thank youu so much, it actually worked but can you tell me how?!

Sign in to comment.

More Answers (0)

Categories

Asked:

on 20 Feb 2018

Commented:

on 22 Feb 2018

Community Treasure Hunt

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

Start Hunting!