0

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
Lemon
  • 12,664

1 Answers1

2

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) $$

Dahn
  • 5,574
  • Oh my goodness, I am an idiot. – Lemon Feb 03 '14 at 06:44
  • Haha, I remember when (not so long ago) I first found out that vector*vector=matrix, I definitely took a bit of time (and thinking) to digest that. – Dahn Feb 03 '14 at 06:46
  • No I didn't realize I defined x to be a row vector in matlab because I was lazy in making a column one. – Lemon Feb 03 '14 at 06:50