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

4 次查看(过去 30 天)
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 个评论
Mohammed Hamaidi
Mohammed Hamaidi 2022-3-23
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

请先登录,再进行评论。

回答(1 个)

Torsten
Torsten 2022-3-21
编辑:Torsten 2022-3-21
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 个评论
Torsten
Torsten 2022-3-23
编辑:Torsten 2022-3-23
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 2022-3-23
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!

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by