%% Use ind2sub with Fewer Output Arguments
% When using ind2sub for an N-dimensional array, you would typically supply N output arguments for each dimension of the matrix. This example shows the different results when you return fewer output arguments for a 3-dimensional array.
% Create the input arguments needed to convert the linear indices 1 through 8 for a 3-dimensional array with size 2-by-2-by-2.

ind = 1:8;
sz = [2 2 2];

% Specify three output arguments when using ind2sub to return the row, column, and page subscripts for the 2-by-2-by-2 array.

[row,col,page] = ind2sub(sz,ind)

% If you specify only two output arguments, ind2sub ignores the third dimension of the array and returns subscripts for a 2-dimensional array with size 2-by-4 instead.

[row,col] = ind2sub(sz,ind)

% If you specify only one output argument, ind2sub ignores the second and third dimensions of the array and returns subscripts for a 1-dimensional array with size 1-by-8 instead.

row = ind2sub(sz,ind)

%
% Copyright 2019 The MathWorks, Inc.