简体   繁体   中英

Symbolic constants in MATLAB

I am playing around with homogeneous transformations in MATLAB. I got a Transformation which looks like this

>> T01

T01 =

[ cos(phi1), -sin(phi1), 0, 0]
[ sin(phi1),  cos(phi1), 0, 0]
[         0,          0, 1, 0]
[         0,          0, 0, 1]

A simple rotation around the z axis. I used phi1=sym('phi1') . Now if i calculate the inverse T01 * inv(T01) MATLAB is not displaying the Identity matrix but rather a matrix with huge expressions. If i use any explicit values for phi1 , it works. How can i make MATLAB cancel out symbolic values?

Thanks

EDIT: Interestingly, for some operations it does cancel out symbolic constants:

>> (phi1*phi2)/phi1

ans =

phi2

Use simplify

>> simplify(T01*inv(T01))


ans =

[ 1, 0, 0, 0]
[ 0, 1, 0, 0]
[ 0, 0, 1, 0]
[ 0, 0, 0, 1]

Probably for performance reasons, only very simple simplification rules are applied automatically in each step.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM