%% Convert Subscripts to Linear Indices for Three-Dimensional Array
% The mapping from subscripts to linear indices for a 2-by-2-by-2 array can be illustrated as in the following.
%
% Specify the row, column, and page subscripts in a 2-by-2-by-2 array. Convert the subscripts to linear indices.

I1 = [1 2 1 2];
I2 = [2 2 1 1];
I3 = [1 1 2 2];
sz = [2 2 2];
ind = sub2ind(sz,I1,I2,I3)

%
% Copyright 2019 The MathWorks, Inc.