%% Toggle Warnings for Low-Rank Matrices
% Solve a linear system involving a low-rank coefficient matrix with warnings turned on.
%
% Create a 3-by-3 matrix that is of rank 2. In this matrix, you can obtain the third column by adding together the first two columns.

A = [1 2 3; 4 5 9; 6 7 13]

%
% Find the minimum norm least-squares solution to the problem \textrm{Ax}=b, where b is equal to the second column in A. Specify the 'warn' flag for lsqminnorm to display a warning if it detects that A is of low rank.

b = A(:,2);
x = lsqminnorm(A,b,'warn')

% Copyright 2012 The MathWorks, Inc.