0% found this document useful (0 votes)
27 views13 pages

Submitted By:: Muhammad Maab Nawaz FA21-EEE-021

This lab report describes generating different line codes such as Polar NRZ, Unipolar NRZ, Unipolar RZ, Manchester, and Delay Modulation using MATLAB code to modulate bit sequences and analyze their power spectral densities. The code implements algorithms to encode data into various line codes and plot the resulting waveforms. The conclusion reflects on learning about line codes, their role in digital communication, exploring their spectral characteristics, and gaining practical experience implementing different line coding schemes in MATLAB.

Uploaded by

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

Submitted By:: Muhammad Maab Nawaz FA21-EEE-021

This lab report describes generating different line codes such as Polar NRZ, Unipolar NRZ, Unipolar RZ, Manchester, and Delay Modulation using MATLAB code to modulate bit sequences and analyze their power spectral densities. The code implements algorithms to encode data into various line codes and plot the resulting waveforms. The conclusion reflects on learning about line codes, their role in digital communication, exploring their spectral characteristics, and gaining practical experience implementing different line coding schemes in MATLAB.

Uploaded by

M4MAAB GAMING
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Lab 9

Generation of PCM Line codes and analyzing their Power Spectral Density
using MATLAB

Submitted By: Muhammad Maab Nawaz


FA21-EEE-021

Submitted To: Dr. Ghufran Shafiq

Submission Date: 1 2 /07/2023

In Lab (4) Post Lab (6) Total (10)


Data Presentation Data Analysis Writing Style
function Bi=modulation(Type)
BITS=[1 0 1 1 0 0 0 1 1 0 1];
fs=1000;
T=0:1/fs:1-1/fs;
Array=[];
%%Type of Modulation
L1='PolarNRZ';
L2='UNIPolarNRZ';
L3='UNIPolarRZ';
L4='Manchester';
L5='Delaymodulation';

%%All waveforms
HalfMark=ones(1,length(T)/2);
Halfspace=-ones(1,length(T)/2);
stepdownward=[HalfMark Halfspace];
stepupward=[Halfspace HalfMark];
Mark=ones(1,length(T));
Space=-ones(1,length(T));
%Polar Nrz
if strcmp(L1,Type)
for i=1:length(BITS)
if BITS(i)==1
Array=[Array ones(length(T))];
else
Array=[Array -ones(length(T))];
end
end
else
disp('')
end

% Unipolar Nrz
if strcmp(L2,Type)
for i=1:length(BITS)
if BITS(i)==1
Array=[Array ones(length(T))];
else
Array=[Array zeros(length(T))];
end
end
else
disp('')
end

% Unipolar RZ
if strcmp(L3,Type)
for i=1:length(BITS)
if BITS(i)==1
Array=[Array stepdownward];
else
Array=[Array zeros(1,length(T))];
end
end
else
disp('')
end

% Manchester
if strcmp(L4,Type)
for i=1:length(BITS)
if BITS(i)==1
Array=[Array stepdownward];

% y=1;
else
Array=[Array stepupward];
end
end
else
disp('')
end

% DelayModulation
if strcmp(L5,Type)
if BITS(1)==1
Array=[Array stepdownward];
else
Array=[Array Mark];
end
for i=2:length(BITS)
if BITS(i)==1
if Array(end-1)>0
Array=[Array stepdownward];
else
Array=[Array stepupward];
end

% y=1;
else
if BITS(i-1)==1
if Array(end-1)>0
Array=[Array Mark];
else
Array=[Array Space];
end
else
if Array(end-1)>0
Array=[Array Space];
else
Array=[Array Mark];
end
end
end
end
else
disp('')
end
plot(1:length(Array),Array,'bl')
grid on
grid minor
ylim([-2 2])
end
bits=[1 0 1 1 0 0 0 1 1 0 1];
Polar Nrz

UNIPolar Nrz

UNIPolar Rz
Manchester

DelayModulation
For random 30 bits
Polar Nrz
UNIPolar Nrz

UNIPolar Rz
Manchester
DelayModulation

Code#2
This code can also be done without concatenation method:
For Manchester:
clc;
clear all;
signal = [1 0 1 1 0 0 0 1 1 0 1];
fs = 1000;
T = 1/fs;
time = 0:1/fs:1-1/fs;
oness= ones(1, (length(time))/2);
zeross= -ones(1, (length(time))/2);
stepdown=[oness zeross];
stepup=[zeross oness];
% mod = zeros(length(time) .* length(bits));
mod=[];
for i = 1:length(signal)
if signal(i) == 1
mod((i-1)*length(time)+1:i*length(time)) = stepdown;
else
mod((i-1)*length(time)+1:i*length(time)) = stepup;
end
end
plot(mod);
ylim([-2 2])
title('Manchester');
grid on;
grid minor

For UNIpolarRZ:
clc;
clear all;
signal = [1 0 1 1 0 0 0 1 1 0 1];
fs = 1000;
T = 1/fs;
time = 0:1/fs:1-1/fs;
Fullbitzero=zeros(1, (length(time)));
oness= ones(1, (length(time))/2);
zeross= zeros(1, (length(time))/2);
stepdown=[oness zeross];
% mod = zeros(length(time) .* length(bits));
mod=[];
for i = 1:length(signal)
if signal(i) == 1
mod((i-1)*length(time)+1:i*length(time)) = stepdown;
else
mod((i-1)*length(time)+1:i*length(time)) = Fullbitzero;
end
end
plot(mod,linewidth=3);
ylim([-2 2])
title('unipolarRZ');
grid on;
grid minor

For UNIpolarNRZ:
clc;
clear all;
signal = [1 0 1 1 0 0 0 1 1 0 1];
fs = 1000;
T = 1/fs;
time = 0:1/fs:1-1/fs;
Fullbitzero=zeros(1, (length(time)));
Fullbitone=ones(1, (length(time)));
mod=[];
for i = 1:length(signal)
if signal(i) == 1
mod((i-1)*length(time)+1:i*length(time)) = Fullbitone;
else
mod((i-1)*length(time)+1:i*length(time)) = Fullbitzero;
end
end
plot(mod,linewidth=3);
ylim([-2 2])
title('unipolarNRZ');
grid on;
grid minor
For polarNRZ:
clc;
clear all;
signal = [1 0 1 1 0 0 0 1 1 0 1];
fs = 1000;
T = 1/fs;
time = 0:1/fs:1-1/fs;
Fullbitspace=-ones(1, (length(time)));
Fullbitone=ones(1, (length(time)));
mod=[];
for i = 1:length(signal)
if signal(i) == 1
mod((i-1)*length(time)+1:i*length(time)) = Fullbitone;
else
mod((i-1)*length(time)+1:i*length(time)) = Fullbitspace;
end
end
plot(mod,linewidth=3);
ylim([-2 2])
title('polarNRZ');
grid on;
grid minor
Conclusion
In this lab I learned about line codes and their role in digital communication. I
learned how these codes represent binary data as electrical signals, ensuring
reliable transmission. Furthermore, I explored the power spectral densities of
various line codes, allowing me to compare their frequency content and understand
their spectral characteristics. By implementing algorithms in MATLAB, I gained
practical experience coding Unipolar NRZ, Bipolar NRZ, Manchester, and Differential
Manchester line codes, solidifying my understanding of their workings. Overall, this
lab was an understanding Line codes and their implementation.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy