%% Select Decomposition Type
% Choose a decomposition type to override the automatic default selection based on the input matrix.
%
% Create a coefficient matrix and decompose the matrix using the default selection of decomposition type.

A = ones(3);
dA = decomposition(A)

%
% Solve the linear system using a vector of ones for the right-hand side.

b = ones(3,1);
x = dA\b

%
% Specify the decomposition type to use the 'qr' method instead of the default 'ldl' method. This forces backslash (\) to find a least-squares solution to the problem instead of returning a vector of NaNs.

dA_qr = decomposition(A,'qr')
x = dA_qr\b

% Copyright 2012 The MathWorks, Inc.