Matlab, "tranpose(x)" not doing it right?

58 Views Asked by At

I just found this really weird thing in matlab,

when I do

  x = [1 2 3];

  tranpose(x)*x

I don't get $14$ as an output, but I get a 3 x 3 matrix

 1     2     3
 2     4     6
 3     6     9
1

There are 1 best solutions below

3
On BEST ANSWER

You want to use x*Transpose(x) as x is an inverted vector.

Transpose(x) is a matrix with three rows and one collumn. x is a matrix with one row and three collumns, thus 3by1 multiplied by 1by3 is according to the rules of matrix multiplication going to be a 3by3 matrix.

This is slightly unintuitive, but if you know matrix (and vector) multiplication, try to multiply these on your own:

$$ \left(\begin{array} \text{1} \\ 2 \\ 3 \end{array}\right) \left(\begin{array} \ 1 \ 2 \ 3\end{array}\right) $$