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]
댓글 수: 0
채택된 답변
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
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)]
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Calculus에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!