%% Cross Product of Multidimensional Arrays
% Create two 3-by-3-by-3 multidimensional arrays of random integers.

A = randi(10,3,3,3);
B = randi(25,3,3,3);

%
% Find the cross product of A and B, treating the rows as vectors.

C = cross(A,B,2)

% The result is a collection of row vectors. For example, C(1,:,1) is equal to the cross product of A(1,:,1) with B(1,:,1).
%
% Find the cross product of A and B along the third dimension (dim = 3).

D = cross(A,B,3)

% The result is a collection of vectors oriented in the third dimension. For example, D(1,1,:) is equal to the cross product of A(1,1,:) with B(1,1,:).
% Copyright 2012 The MathWorks, Inc.