barznjy
Newbie level 6
Dear Friends,
following is the QPSK Tx, Rx matlab code for different channels.
I have these questions:
First:
I don't understand what is mean by (Correct the phase before detection) (y=conj(h).*y? why we need it? how it works? in practical what is that mean?
Second:
In case we have multipath (equalizer), what will change in the system?
I added two path (two different h), but I don't know how to demodulate it.
Third:
Why the contellation diagram of the (slow fading channel) is very strange, since there are a lot of points that cross the origion.
Thank you very much.
clear all; close all; clc;
bits=10^6;
EbN_dB=0:2:16;
EbNo=10.^(EbN_dB/10);
BER=zeros(1,length(EbNo));
for i=1:length(EbN_dB)
% modulation
Ti=(2.*round(randint(1,bits)))-1;
Tq=(2.*round(randint(1,bits)))-1;
x=Ti+1i*Tq;
%generate the channel
h1=1/sqrt(2).*(randn(1,bits)+1i.*rand(1,bits));
h2=1/sqrt(2).*(randn(1,bits)+1i.*rand(1,bits));
n=(1/sqrt(2*EbNo(i)))*(randn(1,bits)+1i*randn(1,bits));
%transmit the signal over flat fading channel
y1=(h1.*x)+n;
y2=(h2.*x)+n;
%Correct the phase before detection
y1=conj(h1).*y1;
y2=conj(h2).*y2;
% demodulation
Ri=sign(real);
Rq=sign(imag);
% ber calculation
BER1=(bits-sum(Ti==Ri))/bits;
BER2=(bits-sum(Tq==Rq))/bits;
BER(i)=mean([BER1 BER2]);
end
semilogy(EbN_dB, BER,'o-')
axis([0 16 10^-6 1]);
hold on
p=qfunc(sqrt(2*EbNo));
semilogy(EbN_dB,2*p-p.^2,'m-','linewidth',1.0);
legend('Simulated QPSK BER Over Rayleigh Fading','Theoritical QPSK BER Over AWGN');
xlabel('EbNo(dB)')
ylabel('BER')
grid on
% plotting constellation diagram
figure(2)
plot(y,'r.');
hold on
plot(x,'bs');
axis([-2 2 -2 2]);
title('Constellation Plot for QPSK' );
grid;
following is the QPSK Tx, Rx matlab code for different channels.
I have these questions:
First:
I don't understand what is mean by (Correct the phase before detection) (y=conj(h).*y? why we need it? how it works? in practical what is that mean?
Second:
In case we have multipath (equalizer), what will change in the system?
I added two path (two different h), but I don't know how to demodulate it.
Third:
Why the contellation diagram of the (slow fading channel) is very strange, since there are a lot of points that cross the origion.
Thank you very much.
clear all; close all; clc;
bits=10^6;
EbN_dB=0:2:16;
EbNo=10.^(EbN_dB/10);
BER=zeros(1,length(EbNo));
for i=1:length(EbN_dB)
% modulation
Ti=(2.*round(randint(1,bits)))-1;
Tq=(2.*round(randint(1,bits)))-1;
x=Ti+1i*Tq;
%generate the channel
h1=1/sqrt(2).*(randn(1,bits)+1i.*rand(1,bits));
h2=1/sqrt(2).*(randn(1,bits)+1i.*rand(1,bits));
n=(1/sqrt(2*EbNo(i)))*(randn(1,bits)+1i*randn(1,bits));
%transmit the signal over flat fading channel
y1=(h1.*x)+n;
y2=(h2.*x)+n;
%Correct the phase before detection
y1=conj(h1).*y1;
y2=conj(h2).*y2;
% demodulation
Ri=sign(real);
Rq=sign(imag);
% ber calculation
BER1=(bits-sum(Ti==Ri))/bits;
BER2=(bits-sum(Tq==Rq))/bits;
BER(i)=mean([BER1 BER2]);
end
semilogy(EbN_dB, BER,'o-')
axis([0 16 10^-6 1]);
hold on
p=qfunc(sqrt(2*EbNo));
semilogy(EbN_dB,2*p-p.^2,'m-','linewidth',1.0);
legend('Simulated QPSK BER Over Rayleigh Fading','Theoritical QPSK BER Over AWGN');
xlabel('EbNo(dB)')
ylabel('BER')
grid on
% plotting constellation diagram
figure(2)
plot(y,'r.');
hold on
plot(x,'bs');
axis([-2 2 -2 2]);
title('Constellation Plot for QPSK' );
grid;