%% Example of how to turn in your work. % EXERCISE 1: % In this example, we are going to take an arbitrary matrix A, and produce % an orthonormal set of vectors that will form the basis for col(A) using % Gram Schmidt A=randn(6,3); %A random matrix A V=zeros(size(A)); V(:,1)=(1/sqrt(A(:,1)'*A(:,1)))*A(:,1); V(:,2)=A(:,2)-(A(:,2)'*V(:,1))*V(:,1); V(:,2)=(1/sqrt(V(:,2)'*V(:,2)))*V(:,2); V(:,3)=A(:,3)-(A(:,3)'*V(:,2))*V(:,2)-(A(:,3)'*V(:,1))*V(:,1); V(:,3)=(1/sqrt(V(:,3)'*V(:,3)))*V(:,3); % Check to see if V is orthonormal V'*V %% Exercise 26, p. 401 % Find the distance from b to the col(U), where U is given below. b=ones(8,1); b(5:8)=-b(5:8); y=b; % To keep with the usual notation, I will use y for b, and % yhat for the projection. U=[-6 -3 6 1 -1 2 1 -6 3 6 3 -2 6 -3 6 -1 2 -1 2 3 -3 6 3 2 -2 -1 2 -3 1 2 1 6]; %We see if U has orthogonal columns: U'*U %% 26, continued. % Next, find the projection of y onto the columnspace of U. Divide % U by 10 and it becomes orthonormal: U1=U/10; yhat=U1*U1'*y; %Projection of y onto the columns of U z=y-yhat; Distance=norm(z) %% Example of embedding a plot clear clc load clown whos image(X); colormap(map);