9.3. How SVD Changes VectorsΒΆ
With the exception of rotation matrices and eigenvectors, we normally
see both rotation and stretching when a point or vector is multiplied by
a matrix. When the matrix is represented by its SVD factors, we see
rotation, stretching, and again rotation when we multiply sequentially
by , , and
.
The showSVD
function may be used to experiment with several
matrices to see the rotation, stretching, and rotation. The
demonstration starts with a set of points on a circle. In the end, the circle
pattern will be changed to show a rotated ellipse. Figures
Fig. 9.4, and Fig. 9.5 show example plots. The
plots will be different for each matrix supplied.
function show_SVD(A)
% SHOW_SVD - A demonstration of how the U, S, and V matrices
% from SVD rotate, stretch, and rotate vectors making a circle.
% Try several 2x2 matrices to see how each behaves.
theta = linspace(0, 2*pi, 30);
x = [cos(theta); sin(theta)];
[U,S,V] = svd(A);
Vx = V'*x;
figure, plot(x(1,:), x(2,:), '*')
hold on
scatter(Vx(1,:), Vx(2,:))
for z = 1:30
line([x(1,z), Vx(1,z)], [x(2,z), Vx(2,z)], 'Color', 'k')
end
title('Rotation by V^T Matrix')
hold off
svx = S*Vx;
figure, scatter(svx(1,:), svx(2,:), '*')
daspect([1 1 1])
usvx = U*svx;
hold on
scatter(usvx(1,:), usvx(2,:), 'o')
title('Stretch by /Sigma and rotation by U')
hold off