Diversity of order 2 over Rayleigh Fading Channel

Status
Not open for further replies.

tomatokid

Newbie level 6
Joined
Sep 3, 2007
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,379
Hi all.. I have the following codes for plotting the BER of a fading channel, with diversity of order 2...
Something seems to be wrong when i combine the receiving signals... Can someone please help?


snr=0:2:24;
for m=1:size(snr,2)
N(m)=0;
efade = 0; % error counter for fading AWGN channel
No = 10^(-snr(m)/10); % PSD of AWGN with signal energy normalise to 1, ie E=1
sigma = sqrt(No/2); % Standard deviation

while(efade ~= 100)
N(m)=N(m)+1;
%for n=1:N
tx_signal = (-1)^round(rand); % to either get a +1 or -1 signal

rfade = 0;
for k=1:2

% channel model
x=randn/sqrt(2);
y=randn/sqrt(2);
p=x^2 + y^2; % fading power of real and imaginary component
a=sqrt(p); % fading amplitude

rfadeTemp = a * tx_signal + sigma*randn; % faded signal + AWGN

rfade = rfade + rfadeTemp;

end; % for


% received signal
if (rfade>0)
estimate_fade = +1;
else
estimate_fade = -1;
end

% checking for error
if (estimate_fade ~= tx_signal)
efade = efade + 1;
end

end %end while

% calculating error probability
pe(m)=efade/N(m); % BER flat Rayleigh fading

% results
fprintf('%f \t %e\n',snr(m),pe(m));
end
semilogy(snr,pe,'-')
%legend('Simulated Rayleigh Fading');
ylabel('Bit Error Rate (BER)');
xlabel('SNR (dB)');
title('Perfomance of BPSK over Rayleigh fading channels');
 

The following code will work fine for rayleigh fading channel.....

clc;
clf;
clear all;
for snr=1:50
snrnum=10^(snr/10);
psk_fading(snr)=0.5*(1-sqrt(snrnum/(1+snrnum)));
end
snr=1:50;
semilogy(snr,psk_fading);
grid on;
datanrzpolar=randsrc(1,1000);
for snr=1:50
signal_amp=sqrt(10^(snr/10))*datanrzpolar;
for mcr=1:100
noise=randn(1,1000);
noise1=randn(1,1000);
cnoise=complex(noise,noise1);
cnoise=cnoise/(sqrt(var(cnoise)));
p_f=2*pi*randn(1,1000);
x1=randn(1,1000);
x2=randn(1,1000);
x1=x1/(sqrt(var(x1)));
x2=x2/(sqrt(var(x2)));
for i=1:1000
alpha(i)=sqrt(x1(i)^2+x2(i)^2);
end
chi=alpha.^2;
chi_mean=mean(chi);
alpha_normalised=alpha./sqrt(chi_mean);
for i=1:1000
h(i)=alpha_normalised(i)*complex(cos(p_f(i)),-sin(p_f(i)));
r(i)=h(i)*signal_amp(i)+cnoise(i);
end
for i=1:1000
mrc(i)=r(i)*conj(h(i));
end;
for i=1:1000
if(real(mrc(i))>=0)
decision(i)=1;
else
decision(i)=-1;
end
end
hamm=0;
for i=1:1000
if(decision(i)~=datanrzpolar(i))
hamm=hamm+1;
end;
end
pe(mcr)=hamm/1000;
end
pepsk(snr)=mean(pe);
end
snr=1:50;
hold on;
semilogy(snr,pepsk,'r*');
grid on;
 

thanks for ur code..
however, the one i need is to have space diversity of order 2...

the above code is only for 1 antenna..
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…