MATLAB's symbolic toolbox is not perfect (perhaps it is impossible to make a perfect symbolic engine), and every year they make some improvements. This seems one such case. Also, "simplification" is not a well defined idea. The tips section of simplify() documentation mentions: "Simplification of mathematical expression is not a clearly defined subject. There is no universal idea as to which form of an expression is simplest. The form of a mathematical expression that is simplest for one problem might be complicated or even unsuitable for another problem."
Are you using an older release of MATLAB? In R2020b, it is simplified as you described in your comment
syms t1 t2 t3 t4 a1 a2 d3
M = [
cos(t4)*(cos(t1)*cos(t2) - sin(t1)*sin(t2)) - sin(t4)*(cos(t1)*sin(t2) + cos(t2)*sin(t1)), - cos(t4)*(cos(t1)*sin(t2) + cos(t2)*sin(t1)) - sin(t4)*(cos(t1)*cos(t2) - sin(t1)*sin(t2)), 0, a1*cos(t1) + a2*cos(t1)*cos(t2) - a2*sin(t1)*sin(t2)
cos(t4)*(cos(t1)*sin(t2) + cos(t2)*sin(t1)) + sin(t4)*(cos(t1)*cos(t2) - sin(t1)*sin(t2)), cos(t4)*(cos(t1)*cos(t2) - sin(t1)*sin(t2)) - sin(t4)*(cos(t1)*sin(t2) + cos(t2)*sin(t1)), 0, a1*sin(t1) + a2*cos(t1)*sin(t2) + a2*cos(t2)*sin(t1)
0, 0, 1, d3
0, 0, 0, 1];
M_simplify = simplify(M)
Result
>> M_simplify
M_simplify =
[cos(t1 + t2 + t4), -sin(t1 + t2 + t4), 0, a2*cos(t1 + t2) + a1*cos(t1)]
[sin(t1 + t2 + t4), cos(t1 + t2 + t4), 0, a2*sin(t1 + t2) + a1*sin(t1)]
[ 0, 0, 1, d3]
[ 0, 0, 0, 1]
You may experiment with following option if you are using an older release of MATLAB
M_simplify = simplify(M, 'Seconds', 10);
Best Answer