MATLAB: Calculate a letter from equation with letters.

equation calculation with letters.

Hello.
I am just wondering that how I can calculate a letter from the equation with letters. For example here,
if I want to get cos1 and sin1 from these equation, how do I need to type the function??
syms Xe Ye a1 a2 cos1 cos2 sin1 sin2
Xe = a2*(cos1*cos2-sin1*sin2)+a1*cos1;
Ye = a2*(sin1*cos2)+a1*sin1;
Thank you in advance.

Best Answer

syms Xe Ye a1 a2 cos1 cos2 sin1 sin2
eqn1=Xe == a2*(cos1*cos2-sin1*sin2)+a1*cos1;
eqn2=Ye == a2*(sin1*cos2)+a1*sin1;
sol = solve([eqn1, eqn2],cos1,sin1)
sol.sin1
sol.cos2