Assignment 5b
Assignment 5b
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
%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