Solving 2 Trigonometric Equation with 2 Unknowns

3 visualizaciones (últimos 30 días)
Ferhat Yamaç UZUN
Ferhat Yamaç UZUN el 18 de Nov. de 2019
Comentada: Stephan el 18 de Nov. de 2019
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)
  1 comentario
David Goodmanson
David Goodmanson el 18 de Nov. de 2019
Hi Ferhat,
In the nine equations, q3 and q4 occur only as the sum (q3+q4). So there is no way to solve for q3 and q4 separately. I think you need to go back to the drawing board and take a look at the conversion from cartesian coordinates to spherical coordinates.
Also, the r matrix is supposed to be orthogonal, so for each row and column, the sum of squares of elements should equal 1. In your case you have 1^2 + .0005^2 + 0^2 = 1 which doesn't work. It does work if the input values r12 and r31 are replaced by +-sqrt(1-.0005^2) in the appropriate spots. That quantity happens to equal +-0.999999874999992 and In the usual Matlab format it would show up as +-1.0000, but it's needed for accuracy.

Iniciar sesión para comentar.

Respuesta aceptada

Stephan
Stephan el 18 de Nov. de 2019
Editada: Stephan el 18 de Nov. de 2019
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.
  2 comentarios
Ferhat Yamaç UZUN
Ferhat Yamaç UZUN el 18 de Nov. de 2019
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
Stephan el 18 de Nov. de 2019
As stated by Davids comment you will need to check if you wrote something meaningful inside your equations. It appears you missed something. However, if you find your mistake, this code will help you finding a solution.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by