Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Dot product

`C = dot(A,B)`

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

`C = dot(`

returns
the scalar dot
product of `A,B`

)`A`

and `B`

.

If

`A`

and`B`

are vectors, then they must have the same length.If

`A`

and`B`

are matrices or multidimensional arrays, then they must have the same size. In this case, the`dot`

function treats`A`

and`B`

as collections of vectors. The function calculates the dot product of corresponding vectors along the first array dimension whose size does not equal 1.

When inputs

`A`

and`B`

are real or complex vectors, the`dot`

function treats them as column vectors and`dot(A,B)`

is the same as`sum(conj(A).*B)`

.When the inputs are matrices or multidimensional arrays, the

`dim`

argument determines which dimension the`sum`

function operates on. In this case,`dot(A,B)`

is the same as`sum(conj(A).*B,dim)`

.

Was this topic helpful?