I am trying to solve a system of equations using fsolve but I keep getting the following error:
Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.Error in root2d (line 4)F(1)=(m*(x1-x3))-(y1-y3);
Below is a snippet of my code, with the function first followed by the main script.
function F = root2d(k,m,x1,y1)x3 = k(1);y3 = k(2);F(1)=(m*(x1-x3))-(y1-y3);F(2)=(sqrt(((y1-k(2))^2)+((x1-k(1))^2)))-1;m = diff(y(xx1));x0 = [0,0];sol = fsolve(@(k)root2d(k,m,x1,y1),x0);
Note: x1 and x2 are scalars defined earlier in the code.
Can anyone help me fix this error? Thank you!
Best Answer