MATLAB: How to use the solve command to solve a system of equations with Cos and Sin in them

system of equations

I need to use solve command to determine the values of three variables in a system of equations. The variables are alfa, which is an angle, Tx which is translation in the x direction, and Ty which is a translation in the y direction. I need to know what these values are. The equations are:
150.75=111.75*cos(alfa)-106.75*sin(alfa)+tx
164.25=121.75*cos(alfa)-110.25*sin(alfa)+tx
177.75=137.75*cos(alfa)-114.75*sin(alfa)+tx
94.25=111.75*cos(alfa)+106.75*sin(alfa)+ty
91.75=121.75*cos(alfa)+110.25*sin(alfa)+ty
94.75=137.75*cos(alfa)+114.75*sin(alfa)+ty

Best Answer

The Symbolic Math Toolbox solve function returns empty variables (even with the ‘=’ replaced by ‘==’, and ‘alfa’ constrained to (0,2*pi)).
The Optimization Toolbox fsolve function returns:
% MAPPING: B(1) = alfa, B(2) = tx, B(3) = ty
fcn = @(B) [-150.75 + 111.75*cos(B(1))-106.75*sin(B(1))+B(2)
-164.25 + 121.75*cos(B(1))-110.25*sin(B(1))+B(2)
-177.75 + 137.75*cos(B(1))-114.75*sin(B(1))+B(2)
-94.25 + 111.75*cos(B(1))+106.75*sin(B(1))+B(3)
-91.75 + 121.75*cos(B(1))+110.25*sin(B(1))+B(3)
-94.75 + 137.75*cos(B(1))+114.75*sin(B(1))+B(3)];
B_est = fsolve(fcn, [3*pi/4, 1, 2])
B_est =
-1.0611 7.3457 129.7382
although with a ‘No solution found.’ warning.
Related Question