Equation expansion using Symbolic Toolbox

2 ビュー (過去 30 日間)
Ravindra
Ravindra 2021 年 3 月 8 日
コメント済み: Ravindra 2021 年 3 月 11 日
Hello all,
I would like to evaluate the quaternion expression using Symbolic Toolbox. I used the following convention.
I used the following code and the subsititutions.
syms g b a I J K real
A = cos(a/2)+ sin(a/2)*I;
B = cos(b/2)+ sin(b/2)*J;
C = cos(g/2)+ sin(g/2)*K;
q_rpy(I,J,K) = C*B*A;
F = expand(q_rpy)
F = subs(F,I*J,K)
F = subs(F,J*K,I)
F = subs(F,I*K,-J)
F = subs(F,K*J,-I)
F = subs(F,I^2,-1)
F = subs(F,J^2,-1)
F = subs(F,K^2,-1)
Is there any way to achieve the correct answer as above?
  2 件のコメント
Paul
Paul 2021 年 3 月 8 日
I don't think this can be done easily because the SMT assumes that multiplication commutes (among other things), which is not true for the "mutliplication" of i, j, and k. So it looks like some user-written functions would be needed. I'm curious if anyone comes up with a simple solution.
Ravindra
Ravindra 2021 年 3 月 9 日
編集済み: Ravindra 2021 年 3 月 9 日
Hi Paul,
you said rightly. Hope someone might have an idea/correct solution.

サインインしてコメントする。

回答 (1 件)

James Tursa
James Tursa 2021 年 3 月 9 日
This has been discussed on this forum before, and there is no easy solution to getting the Symbolic Toolbox to deal with non-commutative objects such as quaternions directly. There are somewhat indirect methods as discussed here:
Another approach is to store all your quaternions as 4-element vectors and call your own quaternion multiply routines.
Finally, you might also be interested in this related post which discusses simplifying quaternion expressions that assume unit quaternions:
  3 件のコメント
John D'Errico
John D'Errico 2021 年 3 月 10 日
編集済み: John D'Errico 2021 年 3 月 10 日
The only real solution is to write your own class. And then it would seem simple.
And of course, the question is is this toolbox is mathematically correct and works:
I've not checked that. I've also not checked to see if it is compatible with the symbolic toolbox. If not, then I would just write a toolbox that was.
Ravindra
Ravindra 2021 年 3 月 11 日
Thanks John. I will check the toolbox on the link you have provided.

サインインしてコメントする。

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by