0% found this document useful (0 votes)
81 views

Matlab Code For Plotting Power Spectral Densities of Data Formats

This MATLAB code generates random binary data and uses it to create NRZ-L, RB, Manchester-L, and RZ signal waveforms. It then performs a Welch power spectral density estimate on each signal and plots the results on the same graph for comparison.

Uploaded by

s.r.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
81 views

Matlab Code For Plotting Power Spectral Densities of Data Formats

This MATLAB code generates random binary data and uses it to create NRZ-L, RB, Manchester-L, and RZ signal waveforms. It then performs a Welch power spectral density estimate on each signal and plots the results on the same graph for comparison.

Uploaded by

s.r.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

MATLAB CODE FOR PLOTTING POWER SPECTRAL DENSITIES OF DATA FORMATS

clc
close all
clear all

Nb=1000; %number of bits


b=randi ([0,1],1,Nb); %generating random sequence of binary numbers
rb=312500; %bit rate in bits/second
tb=(1/312500); %bit interval in seconds
vp=+5;

NRZ_out=[];
Manchester_out=[];
RZ_U_out=[];
RB_out=[];

%NRZ-L waveform
for i=1:size(b,2);
if b(i)==1
NRZ_out= [NRZ_out [ones(1,100)]*vp];
elseif b(i)==0
NRZ_out= [NRZ_out [ones(1,100)]*(-vp)];
end
end
t=tb/100:tb/100:length(b)*tb;

h=spectrum.welch;
Hpsd=psd(h,NRZ_out,'Fs',rb);
figure;
hold on;
handle1=plot(Hpsd);
set(handle1,'Linewidth' ,2.5,'Color','r')

%RB waveform
for i=1:size(b,2);
if b(i)==1
RB_out= [RB_out [ones(1,50),zeros(1,50)]*vp];
elseif b(i)==0
RB_out= [RB_out [ones(1,50),zeros(1,50)]*(-vp)];
end
end

h=spectrum.welch;
Hpsd=psd(h,RB_out,'Fs',rb);
handle2=plot(Hpsd);
set(handle2,'Linewidth' ,2.5,'Color','b')

%Biphase Manchester-L waveform


for i=1:size(b,2);
if b(i)==1
Manchester_out= [Manchester_out [ones(1,50),ones(1,50)*(-1)]*vp];
elseif b(i)==0
Manchester_out= [Manchester_out [ones(1,50),ones(1,50)*(-1)]*(-vp)];
end
end

h=spectrum.welch;
Hpsd=psd(h,Manchester_out,'Fs',rb);
handle3=plot(Hpsd);
set(handle3,'Linewidth' ,2.5,'Color','magenta')

%Unipolar RZ waveform
for i=1:size(b,2);
if b(i)==1
RZ_U_out= [RZ_U_out [ones(1,50), zeros(1,50)]*vp];
elseif b(i)==0
RZ_U_out= [RZ_U_out [zeros(1,100)]];
end
end

h=spectrum.welch;
Hpsd=psd(h,RZ_U_out,'Fs',rb);
handle4=plot(Hpsd);
set(handle4,'Linewidth' ,2.5,'Color','cyan')

legend('NRZ-L','RB','Biphase Manchester-L','Unipolar-RZ');

Welch Power Spectral Density Estimate


-20
NRZ-L
-25 RB
Biphase Manchester-L
-30
Unipolar-RZ

-35
Power/frequency (dB/Hz)

-40

-45

-50

-55

-60

-65

-70
0 50 100 150
Frequency (kHz)

You might also like