%psk.m
t=0:1/1000:1;
Eb=2;
Tb=1;
nc=4;
fc=nc/Tb;
TX=[];
BINSEQ=abs(round(rand(1,200)*2-1));
for m=1:1:200
if(BINSEQ(m)==1)
TX=[TX sqrt(2*Eb/Tb)*cos(2*pi*fc*t)];
else
TX=[TX -1*sqrt(2*Eb/Tb)*cos(2*pi*fc*t)];
end
end
%Adding noise to the band pass signal
RX=TX+sqrt(4)*randn(1,length(TX));
%variance of the additive gaussian noise No/2=4
figure
subplot(2,1,1)
plot(TX(1:1:10001))
title('PSK signal')
subplot(2,1,2)
plot(RX(1:1:10001))
title('PSK with noise ')
%Coherent detection
LO=sqrt(2/Tb)*cos(2*pi*fc*t);
BINSEQDET=[];
CS=[];
for n=1:1:200
temp=RX([(n-1)*1001+1:1:(n-1)*1001+1001]);
S=sum(temp.*LO);
CS=[CS S];
if(S>0)
BINSEQDET=[BINSEQDET 1];
else
BINSEQDET=[BINSEQDET 0];
end
end
figure
subplot(2,2,1)
stem(CS)
title('Output of the correlation receiver')
subplot(2,2,2)
scatter(CS,zeros(1,200))
title('Signal-space diagram for the PSK signal');
subplot(2,2,3)
stem(BINSEQ)
title('Transmitted binary sequence')
subplot(2,2,4)
stem(BINSEQDET)
title('Detected binary sequence')
