%% Control Singular Value Output Format
% Create two 6-by-6 matrices. Use the cat function to concatenate them along the third dimension into a 6-by-6-by-2 array.

A = magic(6);
B = hilb(6);
X = cat(3,A,B);

%
% Calculate the SVD of each array page. By default, pagesvd returns each page of singular values as a diagonal matrix when you specify multiple outputs.

[U,S,V] = pagesvd(X)

%
% Specify the "vector" option to return each page of singular values as a column vector.

[U,S,V] = pagesvd(X,"vector")

% If you specify one output argument, such as S = pagesvd(X), then pagesvd switches behavior to return each page of singular values as a column vector by default. In that case, you can specify the "matrix" option to return each page of singular values as a diagonal matrix.
%
% Copyright 2020 The MathWorks, Inc.