Matlab Code For Plotting Power Spectral Densities of Data Formats
Matlab Code For Plotting Power Spectral Densities of Data Formats
clc
close all
clear all
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')
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');
-35
Power/frequency (dB/Hz)
-40
-45
-50
-55
-60
-65
-70
0 50 100 150
Frequency (kHz)