function svd3
N=20;
M=39;h=1/(M+1);
A=sparse(M,N);
x=(h:h:1-h)';
for i=1:N
  A(:,i)=rand*sin(pi*x)+rand*sin(2*pi*x)+rand*sign(x-0.5)+0.1*rand(M,1);
end
figure(1);hold on;
for i=1:N
  plot(A(:,i))
end
[U, S, V] = svd (A);
figure(2);plot(diag(S));
figure(3);hold on;
plot(A(:,1))
plot(dot(A(:,1),U(:,1))*U(:,1)+dot(A(:,1),U(:,2))*U(:,2)+dot(A(:,1),U(:,3))*U(:,3),'+')
plot(A(:,N/2))
plot(dot(A(:,N/2),U(:,1))*U(:,1)+dot(A(:,N/2),U(:,2))*U(:,2)+dot(A(:,N/2),U(:,3))*U(:,3),'+')
plot(A(:,N))
plot(dot(A(:,N),U(:,1))*U(:,1)+dot(A(:,N),U(:,2))*U(:,2)+dot(A(:,N),U(:,3))*U(:,3),'+')
end