Professional Documents
Culture Documents
Task No. 4
Name : Shaik Suhil Irshad
Reg.no: 18BEC2007
Date : 9 – 03 - 2020
Alorithm:
Representation of message signal.
Generate odd and even part of message signal
Representation of modulated signal using for and if loop
Representation of received QPSK Output
Matlab Code:
Clc
close all
clearall
N=8;
b=randi([0,1],1,N);
bp=2*b1;
bo=bp(1:2:N);
be=bp(2:2:N);
E=1;
T=1;
fc=10;
fs=10*fc;
no=0.3;
snr=10*log10(E/no);
t=0:1/fs:N*T;
cc=sqrt(2/T)*cos(2*pi*fc*t);
cs=sqrt(2/T)*sin(2*pi*fc*t);
m=zeros(size(t));
R=zeros(size(t));
Bo=zeros(size(t));
Be=zeros(size(t));
For i=1:N*T=sqrt(E)*bp(i);
end
fori=1:N*T/2
Bo(2*fs*(i-1)+1:2*fs*i)=sqrt(E)*bo(i);
Be(2*fs*(i-1)+1:2*fs*i)=sqrt(E)*be(i);
end
QPSK=Bo.*cc+Be.*cs;
x=awgn(QPSK,snr);
dc=x.*cc;ds=x.*cs;
ro=zeros(1,N/2);
re=zeros(1,N/2);
r=zeros(1,N);
fori=1:N*T/2 xo=sum(dc(2*fs*(i1)+1:2*fs*i));
xe=sum(ds(2*fs*(i-1)+1:2*fs*i));
if xo>0ro(i)=1;
endif xe>0re(i)=1;
end
endr(1:2:end)=ro;
r(2:2:end)=re;
fori=1:N*T r(fs*(i-1)+1:fs*i)=sqrt(E)*(2*r(i)-1);
end
subplot(4,1,1);
stairs(t,m);
axis([0,N*T,-1.2,1.2]);
xlabel('Time');
ylabel('Amplitude');
title('Message Signal');
subplot(4,1,2);
stairs(t,Bo);
axis([0,N*T,-1.2,1.2]);
xlabel('Time');
ylabel('Amplitude');
subplot(4,1,3);
stairs(t,Be);
axis([0,N*T,-1.2,1.2]);
xlabel('Time');
ylabel('Amplitude');
subplot(4,1,4);
stairs(t,cc);
axis([0,N*T,-1.2,1.2]);
xlabel('Time');
ylabel('Amplitude');
title('Cosine CarrierSignal');
subplot(3,1,1);
plot(t,cs);xlabel('Time');
ylabel('Amplitude');
title('Sine Carrier Signal');
subplot(3,1,2);
plot(t,QPSK);
xlabel('Time');
ylabel('Amplitude');
title('QPSK Signal');
subplot(3,1,3);
plot(t,x);
xlabel('Time');
ylabel('Amplitude');