フィルターのクリア

Display rotation matrix with s1, c1, etc. in place of sind(theta1), cosd(theta1), etc. respectively.

1 回表示 (過去 30 日間)
How can I easily display rotation matrix results by s1, c1, etc. in place of sind(theta1), cosd(theta1), etc. respectively. [theta1, theta2 are defined by syms]

採用された回答

Paul
Paul 2021 年 4 月 11 日
Use subs:
>> doc subs
>> syms theta1 s1 c1
>> A=[cos(theta1) sin(theta1);-sin(theta1) cos(theta1)]
A =
[ cos(theta1), sin(theta1)]
[ -sin(theta1), cos(theta1)]
>> subs(subs(A,cos(theta1),c1),sin(theta1),s1)
ans =
[ c1, s1]
[ -s1, c1]
  3 件のコメント
Paul
Paul 2021 年 4 月 11 日
Use subs() combined with sym() if the variables are named theta1, theta2, etc.
>> syms theta1 theta2 theta3
>> A=[cos(theta1) sin(theta1);-sin(theta1) cos(theta1)];
>> B=[cos(theta2) sin(theta2);-sin(theta2) cos(theta2)];
>> C=[cos(theta3) sin(theta3);-sin(theta3) cos(theta3)];
>> D=A*B*C
D =
[ cos(theta3)*(cos(theta1)*cos(theta2) - sin(theta1)*sin(theta2)) - sin(theta3)*(cos(theta1)*sin(theta2) + cos(theta2)*sin(theta1)), cos(theta3)*(cos(theta1)*sin(theta2) + cos(theta2)*sin(theta1)) + sin(theta3)*(cos(theta1)*cos(theta2) - sin(theta1)*sin(theta2))]
[ - cos(theta3)*(cos(theta1)*sin(theta2) + cos(theta2)*sin(theta1)) - sin(theta3)*(cos(theta1)*cos(theta2) - sin(theta1)*sin(theta2)), cos(theta3)*(cos(theta1)*cos(theta2) - sin(theta1)*sin(theta2)) - sin(theta3)*(cos(theta1)*sin(theta2) + cos(theta2)*sin(theta1))]
>> subs(D,[cos(sym('theta',[1 3])) sin(sym('theta',[1 3]))],[sym('c',[1 3]) sym('s',[1 3])])
ans =
[ c3*(c1*c2 - s1*s2) - s3*(c1*s2 + c2*s1), c3*(c1*s2 + c2*s1) + s3*(c1*c2 - s1*s2)]
[ - c3*(c1*s2 + c2*s1) - s3*(c1*c2 - s1*s2), c3*(c1*c2 - s1*s2) - s3*(c1*s2 + c2*s1)]
Sourabh Karmakar
Sourabh Karmakar 2021 年 4 月 11 日
Fantastic! this is a great solution. Thank you very much.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by