MATLAB: Solving 2 Trigonometric Equation with 2 Unknowns

equationMATLABtrigonometry

Hello everyone !
I've got a graudation project and i stucked in here. Actually I have 6 equations that consist q3 and q4 but I still cannot find the q3 and q4 where the q3,q4 are degree.
Also q1 is known by the given values, here is the code:
px=387.4162;
py=0;
pz=0.0508;
syms q1 q3 q4
r11=0.0005; r12=1; r13=0; r21=0; r22=0; r23=-1; r31=-1; r32=0.0005; r33=0;
q1=atand(py/px);
r11=cosd(q1)*cosd(q3+q4);
r12=-cosd(q1)*sind(q3+q4);
r13=sind(q1);
r21=sind(q1)*cosd(q3+q4);
r22=-sind(q1)*sind(q3+q4);
r23=-cosd(q1);
r31=sind(q3+q4);
r32=cosd(q3+q4);
r33=0;
solve(r11,r12,q3,q4)

Best Answer

You can solve the whole system numeric by using fsolve:
[sol,res]=runfun
function [sol,res] = runfun
px=387.4162;
py=0;
pz=0.0508;
r11=0.0005;
r12=1;
r13=0;
r21=0;
r22=0;
r23=-1;
r31=-1;
r32=0.0005;
r33=0;
q1=atand(py/px);
sol=fsolve(@fun,[1 1])';
res=fun(sol)' % test quality of solution - should be near zero for all equations
function eq = fun(x)
q3=x(1);
q4=x(2);
eq(1)=r11-cosd(q1)*cosd(q3+q4);
eq(2)=r12+cosd(q1)*sind(q3+q4);
eq(3)=r13-sind(q1);
eq(4)=r21-sind(q1)*cosd(q3+q4);
eq(5)=r22+sind(q1)*sind(q3+q4);
eq(6)=r23+cosd(q1);
eq(7)=r31-sind(q3+q4);
eq(8)=r32-cosd(q3+q4);
eq(9)=r33;
end
end
If you do the same but only for the first 2 equations (by commenting the others out) you get:
x=[168.4087, -258.38]
for q3 and q4 which also gives a quiet good result if it is applied to all the equations. You need insight into the problem to decide if this is a meaningful solution.
Related Question