t=-5:1/128:5;
TX=[];
COL=[];
for i=1:1:3
DATABLOCK=(round(rand(1,8))*2-1) + j*(round(rand(1,8))*2-1);
TX=[TX DATABLOCK];
s=0;
for k=1:1:8
s=s+DATABLOCK(k)*exp(j*2*pi*(k-1)*(1/2)*t((i-1)*256+1:1:(i-1)*256+256));
end
COL=[COL s];
figure(2)
subplot(3,1,i)
stem(abs(fft(s,256)))
end
figure(1)
subplot(2,1,1)
plot(t(1:1:length(COL)),real(COL))
subplot(2,1,2)
plot(t(1:1:length(COL)),imag(COL))
%illustration of detection using correlation receiver
t=-5:1/128:5;
D=[];
for i=1:1:3
DATABLOCK=COL((i-1)*256+1:1:(i-1)*256+256);
M=[];
for k=1:1:8
M=[M sum(DATABLOCK.*exp(-j*2*pi*(1/2)*(k-1)*t((i-1)*256+1:1:(i-1)*256+256)))];
end
D=[D M];
end
figure(3)
subplot(2,2,1)
stem(real(TX))
subplot(2,2,2)
stem(real(D))
subplot(2,2,3)
stem(imag(TX))
subplot(2,2,4)
stem(imag(D))