Skip to content

dot

Vector or array dot product.

C = dot(A, B)
C = dot(A, B, dim)

Returns the scalar dot product of vectors A and B, or — when A and B are matrices — a row vector of column-wise dot products. With the optional dim, takes dot products along that dimension. A and B must have the same dimensions.

dot([1 2 3], [4 5 6]) % 32 (1*4 + 2*5 + 3*6)
dot([1 2; 3 4], [5 6; 7 8]) % [26 44] per-column
dot([1 2; 3 4], [5 6; 7 8], 2) % [17; 53] per-row
  • cross — Cross product of two 3-element vectors.
  • mtimes — Matrix multiplication (A * B).