%knownchanneldemo.m
%Flat channel (single tap) with known channel co-efficient
DATA=round(rand(1,10000));
TX=[];
a=1;
%Let the bandwidth of the complex base band signal be W/2
W=2;
N0=0.1;
N0W=(N0/2)*W;
for i=1:1:length(DATA)
if(DATA(i)==0)
TX=[TX a 0];
else
TX=[TX 0 a];
end
end
%Gaussian noise with variance 0.01
g=sqrt(N0W)*randn(1,20000)+j*sqrt(N0W)*randn(1,20000);
%Flat-fading known channel impulse response r
r=2*ones(1,20000)+j*3*ones(1,20000);
RX=r.*TX+g;
figure
subplot(3,1,1)
stem(TX(1:1:200))
title('Typical transmitted samples')
subplot(3,1,2)
plot(real(RX(1:1:200)))
title('Real part of the received samples')
subplot(3,1,3)
plot(imag(RX(1:1:200)))
title('Imaginary part of the received samples')
%detection
DETDATA=[];
for i=1:2:200
temp=[RX(i) RX(i+1)];
O=abs(temp(1))-abs(temp(2));
if(O>0)
DETDATA=[DETDATA 0];
else
DETDATA=[DETDATA 1];
end
end
figure
subplot(2,1,1)
stem(DATA(1:1:100))
title('Transmitted data')
subplot(2,1,2)
stem(DETDATA,'r')
title('Corresponding detected data')
