Simplifying symbolic matrix multiplication with e.g. transpose

Hello
Im strugling with a thing in MATLAB and havent figured out how it can be solved.
How do you tryout math rules like:
(W W^T X)^T * (W W^T X) = X^T W W^T W W^T X
Its not possible to do the following:
syms X W
(W*W'*X)'*(W*W'*X)
transpose((W*transpose(W)*X))*(W*transpose(W)*X)
Which gives: W^4*X^2
or like: (X+W)' = X'+W'.
So to sum up my question: How do you do symbolic math calculations in MATLAB?

 Réponse acceptée

To denote transpose with an apostrophe, you need to type it as
syms X W
(W*W.'*X).'*(W*W.'*X)
which will result in
W^4*X^2

Plus de réponses (1)

Walter Roberson
Walter Roberson le 14 Jan 2018
You cannot do that in MATLAB using anything built in. The symbolic toolbox has no data type corresponding to general matrix with nonspecific entries, not even if you were to specify a particular matrix size. The toolbox only has matrices with specific elements, and it always carries out the entire matrix multiplication giving the matrix of formulas where each symbol mentioned is assumed to be a simple scalar subject to commutivity.
The easiest way by far to handle this is to use a different symbolic package. To program this in MATLAB would require digging deep into the symbolic engine representation of objects in a way that is only accessible by programming in mupad.

2 commentaires

So how do I find a symbolic package like that?
Unfortunately at the moment I do not know which packages can handle that. I was going to say Maple or Mathematica, but when I look more closely those appear to have similar difficulties.
Maple at least has a non-commutative matrix multiplication operator distinct from element-by-element multiplication, but in Maple, transpose applied to a symbol assumes that the symbol is scalar, so in Maple, MatrixMatrixMultiply(W,Transpose(W)) is W^2

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by