%% Example: Projections % First, we'll construct some orthonormal basis vectors that might be % interesting: x=linspace(-pi,pi); %Returns a vector of 100 evenly spaced points between -pi and pi. v1=sin(x)'; v2=sin(3*x)'; v3=cos(x'); V=[v1 v2 v3]; % Does V have orthonormal columns? V'*V temp=sqrt(diag(V'*V)); V=V./repmat(temp',100,1); V'*V % Now we have a three dimensional subspace of R^100. Create some a new % vector in R^100, then project it into the three dimensional subspace. y=exp(-x.^2).*sin(3*x)-cos(4*x); y=y'; %Force y to be a column vector % y is a vector in R^100. Give the three dimensional representation: yc=V'*y % Now get the projection of y into the three dimensional space: yRecon=V*yc; %% Fun with Clowns! % Just for fun: load clown figure(1) image(X); colormap(map); x=linspace(-pi,pi,200)'; v1=sin(x); v2=sin(3*x); v3=sin(5*x); v4=sin(7*x); V=[v1 v2 v3 v4]; temp=sqrt(diag(V'*V)); V=V./repmat(temp',200,1); Coords=V'*X; figure(2) plot3(Coords(1,:),Coords(2,:),Coords(3,:),'.') Recon=V*Coords; figure(3) imagesc(Recon)