How to solve the equation to get the result in atan2 form?

4 Ansichten (letzte 30 Tage)
Shiv Karpoor
Shiv Karpoor am 21 Mär. 2022
Kommentiert: Shiv Karpoor am 23 Mär. 2022
Hello MATLAB Community,
I am trying to solve an equation in MATLAB, but I don't know which function or how to solve it.
syms phi theta psi
ROT = [cos(theta)*cos(phi)+sin(psi)*sin(theta)*sin(phi), -cos(theta)*sin(phi)+sin(psi)*sin(theta)*cos(phi), cos(psi)*sin(theta); ...
cos(psi)*sin(phi), cos(psi)*cos(phi), -sin(psi); ...
-sin(theta)*cos(phi)+sin(psi)*cos(theta)*sin(phi), sin(theta)*sin(phi)+sin(psi)*cos(theta)*cos(phi), cos(psi)*cos(theta)];
eqn = ROT(1,2) == ROT(2,1)
I tried to use functions like solve, simplify, etc. but I am not getting it in the desired form as shown below:
psi = atan2(sin(phi)*sin(theta),cos(phi)+cos(theta))
Can anyone please help me with any suggestions.
Thank you in advance!!
I really appreciate your help.
Kind regards,
Shiv
  5 Kommentare
Mohammed Hamaidi
Mohammed Hamaidi am 23 Mär. 2022
Be careful. The equation has solution under some strict assumptions.
Example:
sin(x)+cos(x)==4
, has no solution,
Matlab gives:
>> solve(cos(x)+sin(x)==4,x)
ans =
-log(- 28i^(1/2)/2 + (2 + 2i))*1i
-log(28i^(1/2)/2 + (2 + 2i))*1i
So, you have to give the assumptions/conditions

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Torsten
Torsten am 21 Mär. 2022
Bearbeitet: Torsten am 21 Mär. 2022
syms phi theta psi
ROT = [cos(theta)*cos(phi)+sin(psi)*sin(theta)*sin(phi), -cos(theta)*sin(phi)+sin(psi)*sin(theta)*cos(phi), cos(psi)*sin(theta); ...
cos(psi)*sin(phi), cos(psi)*cos(phi), -sin(psi); ...
-sin(theta)*cos(phi)+sin(psi)*cos(theta)*sin(phi), sin(theta)*sin(phi)+sin(psi)*cos(theta)*cos(phi), cos(psi)*cos(theta)];
eqn = ROT(1,2) == ROT(2,1);
sol = solve(eqn,psi)
  11 Kommentare
Torsten
Torsten am 23 Mär. 2022
Bearbeitet: Torsten am 23 Mär. 2022
You didn't get David's point.
Your formula to calculate psi as
psi = atan2(sin(phi)*sin(theta),cos(phi)+cos(theta))
seems to be wrong.
But now you know the solution to write psi in terms of phi and theta in symbolic form (the expression from octave). Why don't you simply copy it and use it in your code or whereever you need it ?
Shiv Karpoor
Shiv Karpoor am 23 Mär. 2022
Oh, Okay.
Might be wrong I can't tell, because I got it from journal paper.
I will do as suggested,
Thanks Torsten, I appreciate your help!

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by