Matrix Multiplication with Trigonometric Functions

21 ビュー (過去 30 日間)
N Soomro
N Soomro 2021 年 12 月 1 日
コメント済み: N Soomro 2021 年 12 月 2 日
a = theta1
b = theta2
A = [cos(a+pi) -sin(a+pi)cos(pi/2) sin(a+pi)sin(pi/2) -0.033cos(a+pi);
sin(a+pi) cos(a+pi)cos(pi/2) -cos(a+pi)sin(pi/2) -0.033sin(a+pi);
0 sin(pi/2) cos(pi/2) 0.145;
0 0 0 1]
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses.

Error in connector.internal.fevalMatlab

Error in connector.internal.fevalJSON
B = [cos(b+(pi/2)) -sin(b+(pi/2))cos(0) sin(b+(pi/2))sin(0) 0.155cos(b+(pi/2));
sin(b+(pi/2)) cos(b+(pi/2))cos(0) -cos(b+(pi/2))sin(0) 0.155sin(b+(pi/2));
0 sin(0) cos(0) 0;
0 0 0 1]
Answer = A*B;

回答 (1 件)

Rik
Rik 2021 年 12 月 1 日
The solution is in the error message: in Matlab you need to explicitly use the * operator. In mathematical notation you can generally leave those out, but here you need them.
  5 件のコメント
Walter Roberson
Walter Roberson 2021 年 12 月 2 日
syms theta_1 theta_2
pi = sym(pi);
a = theta_1;
b = theta_2;
A = [cos(a+pi) (-sin(a+pi))*cos(pi/2) (sin(a+pi))*sin(pi/2) -0.033*cos(a+pi);
sin(a+pi) (cos(a+pi))*cos(pi/2) (-cos(a+pi))*sin(pi/2) -0.033*sin(a+pi);
0 sin(pi/2) cos(pi/2) 0.145;
0 0 0 1];
B = [cos(b+(pi/2)) -sin(b+(pi/2))*(cos(0)) sin(b+(pi/2))*(sin(0)) 0.155*cos(b+(pi/2));
sin(b+(pi/2)) cos(b+(pi/2))*(cos(0)) -cos(b+(pi/2))*(sin(0)) 0.155*sin(b+(pi/2));
0 sin(0) cos(0) 0;
0 0 0 1];
Answer = A*B
Answer = 
simplify(Answer)
ans = 
N Soomro
N Soomro 2021 年 12 月 2 日
This is what I was looking for. Thanks a million Mr. Walter Roberson.

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

カテゴリ

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

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by