%% Determine Matrix from Three-Dimensional Array
% Create a 3-D array and determine whether the array elements are a matrix.
% First define a 2-D array of size 2-by-3. Determine whether it is a matrix.

A = [0.1 0.2 0.5; 0.3 0.6 0.4]
TF = ismatrix(A)

% To create a 3-D array, add a third dimension to the array A. Assign another 2-by-3 matrix to the third dimension of A with index value 2.

A(:,:,2) = ones(2,3)

% Check whether the 3-D array of size 2-by-3-by-2 is a matrix.

TF = ismatrix(A)

% Now determine whether the array elements of A are a matrix. Check whether the second page of the 3-D array is a matrix. The syntax A(:,:,2) uses a colon in the first and second dimensions to access all rows and all columns.

TF = ismatrix(A(:,:,2))

% Check whether the second row of the 3-D array is a matrix. The syntax A(2,:,:) uses a colon in the second and third dimensions to include all columns and all pages.

TF = ismatrix(A(2,:,:))

% A(:,:,2) is a matrix since it is a multidimensional array of size 2-by-3. However, A(2,:,:) is not a matrix since it is a multidimensional array of size 1-by-3-by-2.
%
% Copyright 2018 The MathWorks, Inc.