Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Rayleigh one tap fading channel

Status
Not open for further replies.

anta

Member level 1
Joined
Jul 1, 2010
Messages
34
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Greece
Activity points
1,546
Hi all. I am doing ofdm for my diploma thesis and i am facing some problems with rayleigh fading channel....Apparently there's a mistake in my code that i can't find...Any suggestion will be helpful...thank you in advance
Here's my code:


%% DEFINE PARAMETERS %%
%%%%%%%%%%%%%%%%%%%%%%%%%%


M=4;%size of signal constellation

L=1024; % length of data

cp=32;%cyclic prefix


% maximum value of SNR to be simulated (in dB)
max_SNR =25;


%maximum number of iterations
max_ITER =1000;

bits_in_error= zeros(1,max_SNR);
symbols_in_error=zeros(1,max_SNR);




% generate impulse response h of the channel
% independent Rayleigh fading
h=1.*randn(1,1);


%Rayleigh factor
%follows gaussian distribution with mean zero and
%standard deviation 1
%h2=1.*randn(1,K+1);
%energy of the rayleigh factor
%Eh2=sum(abs(h1).^2)/(L);

% h1=heaviside(0);

%h=h2.*h1;

% find frequency response
H=fft(h,L);

% clear figure from previous runs
clf;

%%%%%%%%%%%%%%%%%%%%%%%%%
%% OFDM TRANSMITTER %%
%% %%
%%%%%%%%%%%%%%%%%%%%%%%%%

for iter=1:max_ITER;

%%Modulation
%Modulate using 16-QAM.

%generates random symbols
x=randint(1,L,M);

%qam modulation
y=qammod(x,M);

%normalization according to M-QAM signal constellation
z=y*(1/2)*sqrt(6/(M-1));

%signal energy
Ez=sum(abs(z).^2)/L;

%%IFFT
Z = ifft(z);
%signal energy after the ifft
EZ=sum(abs((Z).^2))/L;

%apply the fourier transform factor
Z1 = sqrt(L)*Z;
%signal energy
EZ1=sum(abs((Z1).^2))/L;

%cyclic prefix

%apply cyclic prefix
Z2 = [Z1(L-cp+1:L) Z1];
%energy of the new signal(with cyclic prefix)
EZ2=sum(abs((Z2.^2))/(L+cp));


%transmitted signal after rayleigh factor applied
Y=Z2*h;





%%%%%%%%%%%%%%%%%%%%%%
%% GAUSSIAN CHANNEL %%
% %%
%%%%%%%%%%%%%%%%%%%%%%

%given SNR in dB
for SNR_dB=1:1:max_SNR
% convert snr
snr=10^(SNR_dB/10);
%find the noise for every SNR
n=sqrt(1/(2*snr))*(randn(1,(L+cp))+j*randn(1,(L+cp)));
%noise energy
En=sum(abs(n.^2))/L;

%find y_noisy for every SNR
ynoisy=Y+n;
%ynoisy=0;

%find the signal energy
Eynoisy=sum(abs(ynoisy.^2))/(L+cp);

%undo cyclic prefix
ynoisy_cut=ynoisy(cp+1:(L+cp));

%ynoisy_cut(without cyclic prefix) energy
Eynoisy_cut=sum(abs(ynoisy_cut.^2))/L;

%signal normalization
Y1=ynoisy_cut./sqrt(L);

%fast fourier transform
Y2=fft(Y1);





%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% OFDM RECEIVER %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%% DEMODULATION %%
%% CHECK y_demod SHOULD BE THE SAME WITH THE TRANSMITTED x when there is no noise applied %%%
%% CHECK y_demod WHEN GAUSSIAN NOISE IS APPLIED%%%%%


%%% undo the rayleigh factor
Y3=Y2./H;


%%% M-QAm normalization
y4=ynoisy_cut*2/sqrt(6/(M-1));

%%%demodulated signal when noise is applied
y_demod=qamdemod(y4,M);

%%difference between transmitted and received signal when noise is applied
y_dif=abs(y_demod-x);



%%%% convert to binary%%%%%%

x_binary=dec2bin(x);
y_demod_binary=dec2bin(y_demod);



%%the difference should be zero when the channel is zero
y_binary=sum(abs(dec2bin(x(1:L))-dec2bin(y_demod(1:L))),2);

%find the total bits in error
total_bits_in_error = sum(y_binary);

%find total symbols in error
total_symbols_in_error=sum(y_dif);

%bits in error for every SNR
bits_in_error(SNR_dB) = bits_in_error(SNR_dB) + total_bits_in_error;

%symbols in error for every SNR
symbols_in_error(SNR_dB)=symbols_in_error(SNR_dB)+total_symbols_in_error;


%%binary difference
%%the difference should be zero when the channel is zero
y_binary_total= sum(sum(dec2bin(x(1:L))-dec2bin(y_demod(1:L)),1),2)/L;

%%shows the binary difference between the symbols due to the noise%%
y_dif_binary=y_demod_binary-x_binary;


end

%end for iter=1:max_ITER
end

%%find bit error rate
BER = bits_in_error/(log2(M)*L)/max_ITER;

%%find symbol error rate
SER=symbols_in_error/(M*L)/max_ITER;


%%BER plot
semilogy(1:max_SNR,BER);
 

any help so far? it's urgent...thank you in advance:D
 

I looked through the site but it didn't help me..
I think that the problem is in the choice of rayleigh factor...
When the channel is flat (aka one tap) what is the rayleigh factor,h..
Since the channel is flat fading h should be the same for every ofdm symbol...

If L is the length of data then h is 1/sqrt(2)*randn(1,L)?

any help?
thanx
 

I have been working on the Rayleigh fading channel in MIMO.

If the no: of transmitters- nt
and no: of receivers - nr

Acc to Rayleigh flat fading channel,

Then channel matrix h= 1/sqrt(nt) * randn(nr,nt)+ sqrt(-1)*randn(nr,nt)

I am not sure whether you are looking for this one.

Regards
 

    anta

    Points: 2
    Helpful Answer Positive Rating
@Lemontre45 thank you for you reply. I've tried simulating according to your suggestion...However the plot is rather similar to the one of an awgn channel...\

So if N is the num of subcarriers
num of taps=1 with one transmitter and one receiver i still wonder which is the right rayleigh factor...

Any suggestion will be helpful
Thanx in advance
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top