%% Access Element of 3-D Array
% Convert a subscript index of a 3-D array to a single linear index.
% Create an array, and find the linear index corresponding to the element in the (2,1,2) position.

A = rand(3,4,2);
linearInd = sub2ind(size(A),2,1,2)

% Check that both index versions refer to the same element.

A(2,1,2)
A(14)

%
% Copyright 2012 The MathWorks, Inc.