clc;
clear all;
close all;
bit=[1 0 0 1 1 0 0 1 0 1 0 0 1 1];
tb=100;
f=1;
be1=[];
bo1=[];
be1na=[];
bo1na=[];
data=[];
for i=1:length(bit)
if bit(i)==0
b=zeros(1,100);
else
b=ones(1,100);
end
data=[data b];
end
for i=1:length(bit)
if mod(i,2)==0
be=bit(i);
be1=[be1 be];
else
bo=bit(i);
bo1=[bo1 bo];
end
end
for i=1:length(be1)
if be1(i)==0
be1n=ones(1,2*tb)*-1;
else
be1n=ones(1,2*tb);
end
be1na=[be1na be1n];
end
for i=1:length(bo1)
if bo1(i)==0
bo1n=ones(1,2*tb)*-1;
else
bo1n=ones(1,2*tb);
end
bo1na=[bo1na bo1n];
end
if length(be1na)<length(bo1na)
be1na=[be1na zeros(1,length(bo1na)-length(be1na))];
else
bo1na=[bo1na zeros(1,length(be1na)-length(bo1na))];
end
t1=linspace(0,2*pi,length(bo1na));
t2=linspace(0,2*pi,length(be1na));
bet=be1na.*sin(3*pi*f*t2)
bot=bo1na.*cos(3*pi*f*t1)
qpsk=bet+bot;
l=length(be1na)+50;
subplot(611);
plot(data,'linewidth',2);grid on;
axis([0,l,-2,2]);
title('Input Bit Stream');
subplot(612);
plot(be1na,'linewidth',2);grid on;
axis([0,l,-2,2]);
title('Even NRZ Signal');
subplot(613);
plot(bo1na,'linewidth',2);grid on;
axis([0,l,-2,2]);
title('Odd NRZ Signal');
subplot(614);
plot(bet,'linewidth',2);grid on;
axis([0,l,-2,2]);
title('EVEN Signal');
subplot(615);
plot(bot,'linewidth',2);grid on;
axis([0,l,-2,2]);
title('Odd Signal');
subplot(616);
plot(qpsk,'linewidth',2);grid on;
axis([0,l,-2,2]);
title('QPSK Signal');