0% found this document useful (0 votes)
13 views4 pages

DC LAB Program

The document describes a MATLAB program that implements the Gram-Schmidt orthogonalization process to generate orthonormal basis vectors from a given set of vectors. It includes code for normalizing the first vector and iteratively subtracting projections onto previous orthonormal vectors for subsequent vectors. The final output is the orthonormalized matrix U, which is displayed to the user.

Uploaded by

aj
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views4 pages

DC LAB Program

The document describes a MATLAB program that implements the Gram-Schmidt orthogonalization process to generate orthonormal basis vectors from a given set of vectors. It includes code for normalizing the first vector and iteratively subtracting projections onto previous orthonormal vectors for subsequent vectors. The final output is the orthonormalized matrix U, which is displayed to the user.

Uploaded by

aj
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Experiment -5:

Write a MATLAB program for Gram-Schmidt orthogonalization: to find orthogonal


basis vectors for the given set of vectors and plot the orthonormal vectors

A = input('Enter the elements of the matrix: ');


[n, k] = size(A);
U = zeros(n, k);

% First vector normalization


U(:,1) = A(:,1) / norm(A(:,1));

for i = 2:k
U(:,i) = A(:,i);
for j = 1:i-1
% Subtract projection onto previous orthonormal vectors
U(:,i) = U(:,i) - (U(:,j)' * A(:,i)) * U(:,j);
end
% Normalize the vector
U(:,i) = U(:,i) / norm(U(:,i));
end
disp('The orthonormalized matrix U is:');
disp(U);

You might also like