# Matlab Line Codes-Digital Communication Systems-Lab Report, Thesis for Digital Communication Systems

9 pages
1000+Number of visits
Description
These are a set of lab reports related to the subject Digital Communication Systems at COMSATS Institute of Information Technology, Lahore by Marrayam Fatima. It includes: Polar, Unipolar, Periodo, Gram, Verification, De...
60 points
this document
Preview3 pages / 9

LINE CODES

POLAR NRZ:

x=randint(1,100);                  t=0:1/10000:1+1/100;         signal=zeros(1,length(t));   bit1=ones(1,100);                 for i=1:length(x) if x(i)==1 signal(1,i*100­99:i*100)=bit1; else signal(1,i*100­99:i*100)=­1*bit1; end end plot(t,signal),axis([0 1 ­2 2]),grid on;

% Randomm Data Of 1's and 0's % Time vector % 0's vector % 1's vector

UNIPOLAR NRZ:

x=randint(1,100);                  t=0:1/10000:1+1/100;         signal=zeros(1,length(t));   bit1=ones(1,100);                 for i=1:length(x) if x(i)==1 signal(1,i*100­99:i*100)=bit1; end end plot(t,signal),axis([0 1 ­2 2]),grid on;

% Randomm Data Of 1's and 0's % Time vector % 0's vector % 1's vector

PERIODO GRAM UNIPOLAR RZ:

test=[1 0 1 1 0 0 0 1 1 0 1]; t=0:1/10000:1/10+1/100; signal=zeros(1,length(t)); bit1=ones(1,50); for i=1:length(test) if test(i)==1 signal(1,i*100-99:i*100-50)=bit1; end end plot(t,signal),axis([0 1.1/10 -2 2]),grid on; X=fftshift(abs(fft(signal(1:138)))); X=X.^2; length(X) X=10/2.2*X; f=-69:1:68; plot(f,X),axis([­100,100,0,400]);

UNIPOLAR RZ:

x=randint(1,100);                  t=0:1/10000:1+1/100;         signal=zeros(1,length(t));   bit1=ones(1,100);                 for i=1:length(x) if x(i)==1 signal(1,i*100­99:i*100)=bit1; end end plot(t,signal),axis([0 1 ­2 2]),grid on;

% Randomm Data Of 1's and 0's % Time vector % 0's vector % 1's vector

VERIFICATION UNIPOLAR RZ:

test=[1 0 1 1 0 0 0 1 1 0 1];   % Test data t=0:1/10000:1/10+1/100; signal=zeros(1,length(t)); bit1=ones(1,50); for i=1:length(test) if test(i)==1 signal(1,i*100­99:i*100­50)=bit1; end end plot(t,signal),axis([0 1.1/10 ­2 2]),grid on;

MANCHESTER:

x=randint(1,100); t=0:1/10000:1+1/100; signal=zeros(1,length(t)); bit1=ones(1,50); for i=1:length(x) if x(i)==1 signal(1,i*100-99:i*100-50)=bit1; signal(1,i*100-49:i*100)=-1*bit1; else signal(1,i*100-99:i*100-50)=-1*bit1; signal(1,i*100-49:i*100)=bit1; end end plot(t,signal),axis([0 1 ­2 2]),grid on;

% Randomm Data Of 1's and 0's % Time vector % 0's vector % 1's vector

VERIFICATIONMANCHESTER:

x=[1 0 1 1 0 0 0 1 1 0 1]; % Test data t=0:1/10000:1+1/10+1/100; signal=zeros(1,length(t)); bit1=ones(1,50); for i=1:length(x) if x(i)==1 signal(1,i*100-99:i*100-50)=bit1; signal(1,i*100-49:i*100)=-1*bit1; else signal(1,i*100-99:i*100-50)=-1*bit1; signal(1,i*100-49:i*100)=bit1; end end plot(t,signal),axis([0 1.1/10 ­2 2]),grid on;

DELAY MODULATION: x=randint(1,100); % Randomm Data Of 1's and 0's t=0:1/10000:1+1/100; % Time vector signal=zeros(1,length(t)); % 0's vector bit1=ones(1,50); % 1's vector previous=bit1; for i=1:length(x) if x(i)==1 signal(1,i*100-99:i*100-50)=previous; signal(1,i*100-49:i*100)=-1*previous; previous=-1*previous; end if x(i)==0 && x(i+1)~=0 signal(1,i*100-99:i*100-50)=previous; signal(1,i*100-49:i*100)=previous; end if x(i)==0 && x(i+1)==0 signal(1,i*100-99:i*100-50)=previous; signal(1,i*100-49:i*100)=previous; previous=-1*previous; end end plot(t,signal),axis([0 1 ­2 2]),grid on;

VERIFICATION DELAY  MODULATION: x=[1 0 1 1 0 0 0 1 1 0 1]; % Test data t=0:1/10000:1/10+1/100; signal=zeros(1,length(t)); bit1=ones(1,50); previous=bit1; for i=1:length(x) if x(i)==1 signal(1,i*100-99:i*100-50)=previous; signal(1,i*100-49:i*100)=-1*previous; previous=-1*previous; end if x(i)==0 && x(i+1)~=0 signal(1,i*100-99:i*100-50)=previous; signal(1,i*100-49:i*100)=previous; end if x(i)==0 && x(i+1)==0 signal(1,i*100-99:i*100-50)=previous; signal(1,i*100-49:i*100)=previous; previous=-1*previous; end end

PERIODO GRAM x=[1 0 1 1 0 0 0 1 1 0 1]; t=0:1/10000:1/10+1/100; signal=zeros(1,length(t)); bit1=ones(1,50); previous=bit1; for i=1:length(x) if x(i)==1 signal(1,i*100-99:i*100-50)=previous; signal(1,i*100-49:i*100)=-1*previous; previous=-1*previous; end if x(i)==0 && x(i+1)~=0 signal(1,i*100-99:i*100-50)=previous; signal(1,i*100-49:i*100)=previous; end if x(i)==0 && x(i+1)==0 signal(1,i*100-99:i*100-50)=previous; signal(1,i*100-49:i*100)=previous; previous=-1*previous; end end

plot(t,signal),axis([0 1.1/10 -2 2]),grid on; X=fftshift(abs(fft(signal(1:138)))); X=X.^2; length(X) X=10/2.2*X; f=-69:1:68; plot(f,X),axis([­100,100,0,400]);

LINE CODES USING PWELCH FUNCTION

POLAR NRZ:

x=randint(1,100); t=0:1/10000:1+1/100; signal=zeros(1,length(t)); bit1=ones(1,100); for i=1:length(x) if x(i)==1 signal(1,i*100-99:i*100)=bit1; else signal(1,i*100-99:i*100)=-1*bit1; end end plot(t,signal),axis([0 1 -2 2]),grid on; [pxx,f]=pwelch(signal,33,[],[],10000) figure,plot(f,pxx)

UNIPOLAR NRZ:

x=randint(1,100); t=0:1/10000:1+1/100; signal=zeros(1,length(t)); bit1=ones(1,100); for i=1:length(x) if x(i)==1 signal(1,i*100-99:i*100)=bit1; end end plot(t,signal),axis([0 1 -2 2]),grid on; [pxx,f]=pwelch(signal,33,[],[],10000) figure,plot(f,pxx)

UNIPOLAR RZ:

x=randint(1,100); t=0:1/10000:1+1/100; signal=zeros(1,length(t)); bit1=ones(1,100); for i=1:length(x) if x(i)==1 signal(1,i*100-99:i*100)=bit1; end end plot(t,signal),axis([0 1 -2 2]),grid on; [pxx,f]=pwelch(signal,33,[],[],10000) figure,plot(f,pxx)

MANCHESTER:

x=randint(1,100); t=0:1/10000:1+1/100; signal=zeros(1,length(t)); bit1=ones(1,50); for i=1:length(x) if x(i)==1 signal(1,i*100-99:i*100-50)=bit1; signal(1,i*100-49:i*100)=-1*bit1; else signal(1,i*100-99:i*100-50)=-1*bit1; signal(1,i*100-49:i*100)=bit1; end end plot(t,signal),axis([0 1 -2 2]),grid on; [pxx,f]=pwelch(signal,33,[],[],10000) figure,plot(f,pxx)

DELAY MODULATION:

x=randint(1,100); t=0:1/10000:1+1/100; signal=zeros(1,length(t)); bit1=ones(1,50); previous=bit1; for i=1:length(x) if x(i)==1 signal(1,i*100-99:i*100-50)=previous; signal(1,i*100-49:i*100)=-1*previous; previous=-1*previous; end if x(i)==0 && x(i+1)~=0 signal(1,i*100-99:i*100-50)=previous; signal(1,i*100-49:i*100)=previous; end if x(i)==0 && x(i+1)==0 signal(1,i*100-99:i*100-50)=previous; signal(1,i*100-49:i*100)=previous; previous=-1*previous; end end plot(t,signal),axis([0 1 -2 2]),grid on; [pxx,f]=pwelch(signal,33,[],[],10000) figure,plot(f,pxx)

DIGITAL COMMUNICATION SYSTEMS        ANALYSIS OF UNIFORM & NON­UNIFORM QUANTIZATION

LAB NO 4