dot
Dot product
C = dot(A, B)
C
contains dot products of vectors taken fromA
andB
along the first non-singleton dimension.A
andB
should have the same sizes.
C = dot(A, B, dim)
C
contains dot products of vectors taken fromA
andB
along thedim
-th dimension.A
andB
should have the same sizes.dim
should be positive integer not greater than the number of dimensions ofA
orB
.
Example 1: Dot products of vectors along different dimensions.
a=randi(3,3,4) b=randi(3,3,4) % Dot products of vectors along the first % non-singleton dimension. dot(a,b) % Dot products of vectors along the % second dimension. dot(a,b,2)
a = 2.000 3.000 2.000 3.000 2.000 3.000 1.000 1.000 2.000 2.000 2.000 1.000 b = 3.000 3.000 2.000 2.000 1.000 2.000 3.000 3.000 3.000 2.000 1.000 1.000 ans = 14.00 19.00 9.000 10.00 ans = 25.00 14.00 13.00