You are on page 1of 11

PART-B: Simulation Experiments using MATLAB

EXPERIMENT-1

Aim: Simulate NRZ, RZ, half-sinusoid and raised cosine pulses and generate eye
diagram for binary polar signaling.

Software Used: MATLAB

Theory : Data as well as signals that represents data can either be digital or analog. Line
coding is the process of converting digital data to digital signals. By this technique we converts
a sequence of bits to a digital signal. At the sender side digital data are encoded into a digital
signal and at the receiver side the digital data are recreated by decoding the digital signal.

1. Unipolar Non-Return to Zero (NRZ):

In this type of unipolar signaling, a High in data is represented by a positive pulse called as Mark,
which has a duration T0 equal to the symbol bit duration. A Low in data input has no pulse.
The following figure clearly depicts this.

Advantages
The advantages of Unipolar NRZ are −
 It is simple.
 A lesser bandwidth is required.
Disadvantages
The disadvantages of Unipolar NRZ are −
 No error correction done.
 Presence of low frequency components may cause the signal droop.
 No clock is present.
 Loss of synchronization is likely to occur (especially for long strings of 1s and 0s).

2. Unipolar Return to Zero (RZ)

In this type of unipolar signaling, a High in data, though represented by a Mark pulse, its
duration T0 is less than the symbol bit duration. Half of the bit duration remains high but it
immediately returns to zero and shows the absence of pulse during the remaining half of the bit
duration.
It is clearly understood with the help of the following figure.

Advantages
The advantages of Unipolar RZ are −

 It is simple.
 The spectral line present at the symbol rate can be used as a clock.
Disadvantages
The disadvantages of Unipolar RZ are −

 No error correction.
 Occupies twice the bandwidth as unipolar NRZ.
 The signal droop is caused at the places where signal is non-zero at 0 Hz.
Polar Signaling
There are two methods of Polar Signaling. They are −

 Polar NRZ
 Polar RZ
1. Polar NRZ
In this type of Polar signaling, a High in data is represented by a positive pulse, while a Low in
data is represented by a negative pulse. The following figure depicts this well.

Advantages
The advantages of Polar NRZ are −

 It is simple.
 No low-frequency components are present.
Disadvantages
The disadvantages of Polar NRZ are −
 No error correction.
 No clock is present.
 The signal droop is caused at the places where the signal is non-zero at 0 Hz.

2. Polar RZ:

In this type of Polar signaling, a High in data, though represented by a Mark pulse, its
duration T0 is less than the symbol bit duration. Half of the bit duration remains high but it
immediately returns to zero and shows the absence of pulse during the remaining half of the bit
duration.
However, for a Low input, a negative pulse represents the data, and the zero level remains same
for the other half of the bit duration. The following figure depicts this clearly.

Advantages
The advantages of Polar RZ are −

 It is simple.
 No low-frequency components are present.
Disadvantages
The disadvantages of Polar RZ are −
 No error correction.
 No clock is present.
 Occupies twice the bandwidth of Polar NRZ.
 The signal droop is caused at places where the signal is non-zero at 0 Hz.

MATLAB Code:
1. NRZ(Polar and Unipolar):

N = input('Enter the length of bitstream');

bitstream = rand(1,N) > 0.5

timeperiod = input('Enter the timeperiod (No. of samples)');%samples

time = 0:(timeperiod*length(bitstream)-1); %Time period = 100 samples.

repeat = ones(1,timeperiod);

NRZP = bitstream.' * repeat;

NRZP = NRZP.';

NRZP = NRZP(:)';

%Unipolar

NRZU = NRZP;

figure(1)

subplot(2,2,1)

plot(time,NRZU);axis([0,10*timeperiod,-1.5,1.5]);

title('NRZ Unipolar')

xlabel('Time(s)')

ylabel('Voltage(V)')
%Polar

NRZP = (2.*NRZP) - ones(1,length(NRZP));

subplot(2,2,2)

plot(time,NRZP);axis([0,10*timeperiod,-1.5,1.5]);

title('NRZ Polar')

xlabel('Time(s)')

ylabel('Voltage(V)')

2. RZ(Polar and Unipolar):

intermediate = ones(1,length(bitstream)*2);

intermediate(2:2:length(intermediate)) = 0;

intermediate = intermediate.' * ones(1,(timeperiod/2));

intermediate = intermediate.';

intermediate = intermediate(:)';

%Unipolar

RZU = NRZU .* intermediate;

subplot(2,2,3)

plot(time,RZU);axis([0,10*timeperiod,-1.5,1.5]);

title('RZ Unipolar')

xlabel('Time(s)')

ylabel('Voltage(V)')

%Polar

RZP = NRZP .* intermediate;

subplot(2,2,4)
plot(time,RZP);axis([0,10*timeperiod,-1.5,1.5]);

title('RZ Polar')

xlabel('Time(s)')

ylabel('Voltage(V)')

Result: Line coding NRZ and RZ has been simulated using MATLAB.

RAISED COSINE & HALF SINUSOID

The raised-cosine filter is a filter frequently used for pulse-shaping in digital modulation due to
its ability to minimise intersymbol interference (ISI). Its name stems from the fact that the non-
zero portion of the frequency spectrum of its simplest form ( 𝛽 = 1)is a cosine function, 'raised'
up to sit above the 𝑓 (horizontal) axis.It is a filter whose frequency-domain shape is 1 at DC and
extends out flat for some distance, then transitions to zero, where the transition takes the shape of
a raised cosine, and the transition is centered at the symbol rate. The width of the transition is
variable, and is controlled by a parameter𝛽. This sort of filter is used by many communication
standards.

(a) (b)

Fig.1 (a) Time response of raised-cosine filter with various roll-off factors (b)Frequency
response of raised-cosine filter with various roll-off factors

Matlab Code for raised cosine pulse with its eye pattern.

clc;
clear all;

close all;

%% Unipolar Raised Cosine


beta = 0.5; % try with different values of
beta from 0 to 1 (roll-off factor)
T = 1;
t = linspace(0,(1+beta)/2/T,50); %linearly spaced vectors
(1x50) vectors
h = 1*(t<((1-beta)/2/T)) + (0.5*(1+cos(pi*T/beta*(t-(1-
beta)/2/T)))) .* (t>=((1-beta)/2/T));
t = [-fliplr(t(2:end)),t]; %Flip matrix in left/right
direction
h = [fliplr(h(2:end)),h];

bk = rand(1,100)>0.5;
x = bk'*h;
x = x';
x = x(:)';
t = 0:1/100:98+99/100;
subplot(211);plot(t,x); axis([0,10,-1,1]);

X = abs(fftshift(fft(x)));
X = X/max(X);
f = linspace(-50,50,length(X));
subplot(212);plot(f,X);axis([-5,5,0,1]);

%% Polar Raised Cosine

bk = 2*bk-1;
x = bk'*h;
x = x';
x = x(:)';
t = 0:1/100:98+99/100;
figure();
subplot(211);plot(t,x); axis([0,10,-1,1]);

X = abs(fftshift(fft(x)));
X = X/max(X);
f = linspace(-50,50,length(X));
subplot(212);plot(f,X);axis([-5,5,0,1]);
eyediagram(x,99)

Waveforms of raised cosine pulse


Matlab code for half sinusoid pulse
close all;

%% Unipolar Half-sinusoid
bk = rand(1,100)>0.5;
x = bk'*sin(2*pi/200*[0:99]);
x = x';
x = x(:)';

t = 0:1/100:100-1/100;
subplot(211);plot(t,x);axis([0,10,-1,1]);

X = abs(fftshift(fft(x)));
X = X/max(X);
f = linspace(-50,50,length(X));
subplot(212);plot(f,X);axis([-5,5,0,1]);

%% Polar Half Sinusoid

bk = 2*bk-1;
x = bk'*sin(2*pi/200*[0:99]);
x = x';
x = x(:)';

t = 0:1/100:100-1/100;
figure();
subplot(211);plot(t,x);axis([0,10,-1,1]);

X = abs(fftshift(fft(x)));
X = X/max(X);
f = linspace(-50,50,length(X));
subplot(212);plot(f,X);axis([-5,5,0,1]);
eyediagram(x,100)

Waveforms of half sinusoid pulse

You might also like