Vous êtes sur la page 1sur 4

QPSK

clc;
b = input('Enter the bit stream = ');
n = length(b);
t = 0:0.01:n;
x = 1:1:(n+2)*100;
for i = 1:n
if (b(i) == 0)
u(i) = -1;
else
u(i) = 1;
end
for j = i:0.1:i+1
bw(x(i*100:(i+1)*100)) = u(i);
if (mod(i,2) == 0)
bw_e(x(i*100:(i+1)*100)) = u(i);
bw_e(x((i+1)*100:(i+2)*100)) = u(i);
else
bw_o(x(i*100:(i+1)*100)) = u(i);
bw_o(x((i+1)*100:(i+2)*100)) = u(i);
end
if (mod(n,2)~= 0)
bw_e(x(n*100:(n+1)*100)) = -1;
bw_e(x((n+1)*100:(n+2)*100)) = -1;
end
end
end
bw = bw(100:end);
bw_o = bw_o(100:(n+1)*100);
bw_e = bw_e(200:(n+2)*100);
cost = cos(2*pi*t);
sint = sin(2*pi*t);
x = bw_o.*cost;
y = bw_e.*sint;
z = x+y;
subplot(3,2,1);
plot(t,bw);
xlabel('n ---->');
ylabel('Amplitude ---->');
title('Input Bit Stream');
grid on ;
axis([0 n -2 +2]);
subplot(3,2,5);
plot(t,bw_o);
xlabel('n ---->');
ylabel('Amplitude ---->');
title('Odd Sequence');
grid on ;
axis([0 n -2 +2]);
subplot(3,2,3);
plot(t,bw_e);
xlabel('n ---->');
ylabel('Amplitude ---->');
title('Even Sequence');
grid on ;
axis([0 n -2 +2]);
subplot(3,2,4);
plot(t,x);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('Odd Sequence BPSK Modulated Wave');
grid on ;
axis([0 n -2 +2]);
subplot(3,2,2);
plot(t,y);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('Even Sequence BPSK Modulated Wave');
grid on ;
axis([0 n -2 +2]);
subplot(3,2,6);
plot(t,z);
xlabel('Time ---->');
ylabel('Amplitude ---->');
title('QPSK Modulated Wave');
grid on ;
axis([0 n -2 +2]);
BPSK
clc;
clear all;
close all;
d=[1 1 0 1 0 1 0];
bit=[];
for n=1:1:length(d)
if d(n)==1
se=ones(1,100);
else d(n)==0
se=zeros(1,100);
end
bit=[bit se];
end
t=linspace(1,length(d),100*length(d));
subplot(3,1,1);
plot(t,bit);
A1=10; % Amplitude of carrier signal
f=10; % carrier frequency
t2=linspace(0,1,10);
ss=length(t2);
m=[];
for (i=1:1:length(d))
if (d(i)==1)
y=A1*cos(2*pi*f*t2);
else
y=A1*cos((2*pi*f*t2)+pi);
end
m=[m y];
end
t3=linspace(1,length(d),10*length(d));
subplot(3,1,2);
plot(t3,m);
mn=[];
for n2=10:10:length(m)
tc= linspace(0,1,10);
y1=cos(2*pi*f*tc); % carrier signal
mm=y1.*m(n2-(10-1):n2);
t4=linspace(0,1,10);
z=trapz(t4,mm) % integration
zz=round((2*z/1))
if(zz>0)
a=1;
else
a=0;
end
mn=[mn a];
end
disp(' Binary information at Reciver :');
disp(mn);
rbit=[];
for n=1:1:length(mn)
if mn(n)==1
se=ones(1,100);
else d(n)==0
se=zeros(1,100);
end
rbit=[rbit se];
end
t=linspace(1,length(mn),100*length(mn));
subplot(3,1,3);
plot(t,bit);

Vous aimerez peut-être aussi