0% found this document useful (0 votes)
45 views1 page

K F U P & M: Name: Syed Awais Wahab Shah ID: 201303510

This document contains a Matlab code that implements the Gram-Schmidt process to generate orthonormal vectors from an input matrix. The code takes the input matrix, calculates the projections of each vector onto the previous vectors, subtracts these projections to make the vectors orthogonal, and normalizes them to make them orthonormal. It then displays the number of orthonormal vectors generated and verifies that all vectors are orthogonal to each other.

Uploaded by

Syed Awais Wahab
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)
45 views1 page

K F U P & M: Name: Syed Awais Wahab Shah ID: 201303510

This document contains a Matlab code that implements the Gram-Schmidt process to generate orthonormal vectors from an input matrix. The code takes the input matrix, calculates the projections of each vector onto the previous vectors, subtracts these projections to make the vectors orthogonal, and normalizes them to make them orthonormal. It then displays the number of orthonormal vectors generated and verifies that all vectors are orthogonal to each other.

Uploaded by

Syed Awais Wahab
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
You are on page 1/ 1

KING FAHD UNIVERSITY OF PETROLEUM & MINERALS

DIGITAL COMMUNICATIONS I
ASSIGNMENT 1

Name: Syed Awais Wahab Shah
ID: 201303510

Task: Matlab code for Gram-Schmidth Process, also show No. of orthonormal vectors and verify that
vectors are orthonormal to each other.
Solution:
% v is the input matrix of m * n
% where m = No. of elements of vectors
% and n = No. dimensions of vectors
% u is the output orthonormal matrix of order m * min(m,n)
function gram_schmidth(v)
n=size(v); %this will extract the index of v
u=zeros(n(1), min(n)); %initally making output matrix zero
for i=1:min(n) %loop from 1 to min(m,n)
x=zeros(n(1),1); %vector for computing projections
for j=1:i %loop for computing projections
x=x+(v(:,i)'*u(:,j))*u(:,j); %sum of projections
end
u(:,i)=v(:,i)-x; %subtract projections from vector
u(:,i)=u(:,i)/norm(u(:,i)); %normalizing to get unit vector
end
sprintf('No. of Orthonormal Vectors are %d', length(u(1,:)))
disp('Orthogonal vectors are')
u
%Verification of orthonormality of vectors
flag=0; %flag for orthonormality
for i=2:length(u(1,:))
for j=1:i-1
if(u(:,i)'*u(:,j)>0.1) %condition of orthonormality
sprintf('vector %d is not orthogonal to %d',i,j)
flag=1;
end
end
end
if(flag==0)
disp('all vectors are orthonormal to each other')
end

You might also like