# Matrix Multiplication with Trigonometric Functions

9 views (last 30 days)
N Soomro on 1 Dec 2021
Commented: N Soomro on 2 Dec 2021
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]

Rik on 1 Dec 2021
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.
N Soomro on 2 Dec 2021
This is what I was looking for. Thanks a million Mr. Walter Roberson.

VBBV on 2 Dec 2021
theta1 = pi*2/3;
theta2 = 2;
A = [-cos(theta1) 0 -sin(theta1) 0.033*cos(theta1);
-sin(theta1) 0 cos(theta1) 0.033*sin(theta1);
0 1 0 0.145;
0 0 0 1];
B = [-cos(theta2) -cos(theta2) 0 -0.155*cos(theta2);
cos(theta2) -sin(theta2) 0 0.155*sin(theta2);
0 0 1 0;
0 0 0 1];
0.2081 0 0 -0.0011 0.3604 0 0 0.0040 0 0 0 0 0 0 0 1.0000
N Soomro on 2 Dec 2021
Thank you VBBV. I can see you have substituted values for variables 'theta1' and 'theta2' respectively. Is there any way to determine what the final product of matrices A and B would be without substituting values? (i.e. a resultant 4 x 4 matrix simplified in terms of both theta1 and theta2). Many thanks.

R2021b

### Community Treasure Hunt

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

Start Hunting!