Vector cross product
Syntax
W = cross(U,V)
W = cross(U,V,dim)
Description
W = cross(U,V)
returns the cross product of the vectors U and V. That is,
W = U x V. U and V are usually 3-element vectors. If U and V are multidimensional arrays, cross returns the cross product of U and V along the first dimension of length 3.
If U and V are arrays, cross(U,V) treats the first size 3 dimension of U and V as vectors, returning pages whose columns are cross products.
W = cross(U,V,dim)
where U and V are multidimensional arrays, returns the cross product of U and V in dimension dim . U and V must have the same size, and both size(U,dim) and size(V,dim) must be 3.
Remarks
To perform a dot (scalar) product of two vectors of the same size, use:
c = sum(a.*b) or, if a and b are row vectors, c = a.'*b.
Examples
The cross and dot products of two vectors are calculated as shown:
a = [1 2 3]; b = [4 5 6];
c = cross(a,b)
c =
-3 6 -3
d = sum(a.*b)
d =
32
[ Previous | Help Desk | Next ]