close all;

theta1 = pi/6;
theta2 = pi/3;
V = [cos(theta1), -sin(theta1); sin(theta1), cos(theta1)];
U = [cos(theta2), -sin(theta2); sin(theta2), cos(theta2)];
S = mdiag(2, 0.5);
M = U*S*V';

%M = rand(2,2)

[U,S,V] = svd(M);

a_hist = [];
b_hist = [];
for theta=0:0.1:2*pi
  a = [cos(theta); sin(theta)];
  b = M*a;
  figure(1);
  plot(a(1), a(2), 'bo', b(1), b(2), 'r*');
  axis([-2, 2, -2, 2]);
  grid on;
  hold on;

  pause
end

figure(1);
plot([V(1,1); 0], [V(2,1); 0], 'b-', [V(1,2); 0], [V(2,2); 0], 'b--');
plot([S(1,1)*U(1,1); 0], [S(1,1)*U(2,1); 0], 'r-', [S(2,2)*U(1,2); 0], [S(2,2)*U(2,2); 0], 'r--');
