Asked by Ferhat Yamaç UZUN
on 18 Nov 2019 at 19:12

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)

Stephan
님의 답변 18 Nov 2019 22:09

Stephan
님이 편집함. 18 Nov 2019 22:41

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.

Ferhat Yamaç UZUN
18 Nov 2019 22:33

Let me understand clearly because your code looks complicated for me, if i say so myself. I'm trying to find the q3 and q4 values in degree.

As I understand from your code q3 and q4 are both -44.9857 ?!?

Here is the output from my screen:

Warning: Trust-region-dogleg algorithm of FSOLVE cannot handle non-square systems; using Levenberg-Marquardt algorithm instead.

> In fsolve (line 316)

In matlab96>runfun (line 16)

In matlab96 (line 1)

Equation solved.

fsolve completed because the vector of function values is near zero

as measured by the value of the function tolerance, and

the problem appears regular as measured by the gradient.

<stopping criteria details>

res =

1.0e-06 *

0.0001

0.1250

0

0

0

0

-0.1250

0.0001

0

sol =

-44.9857

-44.9857

res =

1.0e-06 *

0.0001

0.1250

0

0

0

0

-0.1250

0.0001

0

Stephan
18 Nov 2019 22:45

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 1 Comment

## David Goodmanson (view profile)

## 이 댓글에 대한 바로 가기 링크

https://kr.mathworks.com/matlabcentral/answers/491752-solving-2-trigonometric-equation-with-2-unknowns#comment_768690

Sign in to comment.