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

Assignment 5b

The document demonstrates DPSK modulation and demodulation. It generates a random input bit sequence, differentially encodes it, maps it to a unipolar NRZ signal, modulates it with a carrier signal, and demodulates the output to recover the original bits. Plots are shown of the encoded input, carrier, modulated, and demodulated signals.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Assignment 5b

The document demonstrates DPSK modulation and demodulation. It generates a random input bit sequence, differentially encodes it, maps it to a unipolar NRZ signal, modulates it with a carrier signal, and demodulates the output to recover the original bits. Plots are shown of the encoded input, carrier, modulated, and demodulated signals.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

%DPSK modulation and demodulation

clc;
close all;
clear all;
b=[1 0 1 1 0 1 0 1 0 ]; % input bits

%Differential encoding
d=1;%initial bit
dc=[];
for i=1:length(b)
dc=[dc d];
d=not(xor(d,b(i)));
end
dc=[dc d];

%polar mapping
for ii=1:length(dc)
if dc(ii)==1
nn(ii)=1;
else
nn(ii)=-1;
end
end

%unipolar NRZ signal


s=100;
i=1;
t=0:1/s:length(dc);
for j=1:length(t)
if t(j)<=i
m(j)=nn(i);
else
m(j)=nn(i);
i=i+1;
end
end
subplot(4,1,1);
plot(t,m);
xlabel('time');
ylabel('amplitude');
title('differentially encoded input');

%carrier
fc=150000;
t1=0:0.0000001:0.0001;
c=sin(2*pi*fc*t1);
subplot(4,1,2);
plot(t1,c);
xlabel('time');
ylabel('amplitude');
title('carrier');

1
x=m.*c;
subplot(4,1,3);
plot(t1,x);
xlabel('time');
ylabel('amplitude');
title('Dpsk modulated waveform');
%demodulation
y=x.*c;
int_op=[];
for ii=0:s:length(y)-s
int_o=(1/s)*trapz(y(ii+1:ii+s));
int_op=[int_op int_o];
end
th=0; %threshold value
det=(round(int_op,1)>=th);
for iii=1:length(det)
if det(iii)==0
nnn(iii)=0;
else
nnn(iii)=1;
end
end
s=100;
i=1;
t=0:1/s:length(dc);
for j=1:length(t)
if t(j)<=i
k(j)=nnn(i);
else
k(j)=nnn(i);
i=i+1;
end
end
subplot(4,1,4);
plot(t,k);
xlabel('time');
ylabel('amplitude');
title('demodulation of DpSK');

2
Published with MATLAB® R2020b

You might also like