### 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.

Status
Not open for further replies.

#### israilsaifi

##### Newbie level 1

how one can generate two path fading and transmiits ddata on it in matlab ?

#### gaffar

##### Member level 1

You can use communications blockset in matlab. There is Rayleigh Fading Channel block in blockset and you can simulate implementing a simple simulink model.

arham_itt

### arham_itt

Points: 2

#### tarakapraveen

##### Member level 5

hi
You can use the Clarke's model given in the Rappaport book.
In that what they did was Rayleigh fading envelope is combination of two Gaussian Sources like as

Define
Gaussian : randn(1,100)

Rayleigh :randn(1,100)+j*randn(1,100);

if u plot absolute value of above equation in Matlab you ll get the rayleigh envelope.But in the fading environment case we are experiencing Doppler shift so we hav to design a filter with that doppler frequency and pass that Rayleigh faded signal i.e above 2nd one through that filter.

If any mistakes correct me
Regards,
Taraka

#### amihomo

##### Full Member level 5
rayleighchan

hi

you can use a 2-tap delay line to model a two path rayleigh fading channel , i.e. , if x is the signal passed through the channel , the output of the channel will be :
y=a1.*x+a2.*x(n-taw)

where a1 and a2 are rayleigh random variables (slow rayleigh fading envelopes in each path) and taw is the relative delay between two paths .

regards

#### bee

##### Full Member level 2

if u use this eq for the Rayleigh :randn(1,100)+j*randn(1,100);
then i think you need to divide it by sqrt(2) to make the var = 1.

correct me if am not right.

#### maomun

##### Junior Member level 3

hello

if u have matlab version 7(or higher) , then type this in command window.

"help rayleighchan"

sweet

#### waqasbukhari

##### Newbie level 4

i would try to elaborate the whole concept in mathematical language.
rayleigh fading channel consists of two random variables
1 - channel impulse response of each multipath component and it can be approximated by a gaussian distribution.
2 - impact of scattering environment on each componen.

both of these have gaussian approximations with zero mean and finite variance and central limit theorem permits us to model them as gaussian approximation.

now, the whole channel response can be a rayleigh approximations and its equivalent equation can be something like

now my credibility:
i am UG student doing my FYP in improving the transmission strategies by overcoming the fading effects.

bye

one more thing to elaborate what Mr. Taraka suggested.
he is all right if the generated random numbers are between -1 to 1 so that each one of them is approximated by gaussian distribution and both the generated random variables are qualified to be independent and identically distributed ie, their mutual cross correlation must be zero and their distributions are gaussian. then we can compute the magnitude of the vector which would be then come out to be rayleigh distributed.
bye

#### vuday455

##### Newbie level 5

could u pls anyone explain me how can i use the 'rayleighchan' function in loop for simulation of ofdm system..

i passed the say 100 symbols through this rayleighchan function and i added indivually awgn ...then after demodulation i ploted the ber curve.

i am appending my code..is my code is correct..pls correct it if any wrong..

and also pls let me know abt how can i modify the code for working in case of varying dopler frequency..

<-----------------------------**********************------------------------------->

% ofdm system design ...

% BW = input('enter the channel bandwidth :');
% Nused = input('enter the number of subcarriers :');
% n_factor = input('enter the sampling factor :');
% G = input('enter the ration of CP time to Useful time :');
clear all
close all
clc
BW = 1.75e6;
Nused = 200;
n_factor = 8/7;
G = 1/4;

[Nfft,Fs,delta_f,Tb,Tg,Ts,sampling_time] = derived_parameters(BW,Nused,n_factor,G);

% Nfft-->fft size , Fs-->sampling frequency , delta_f-->suhcarrier spacing
% Tb--> useful symbol time, Tg-->guard/CP time, Ts-->OFDM Symbol
% time (Tb+Tg)
N_prefix = Nfft*G;
N_data = 192;
N_pilot = 8;
SNR = 0:2:20; % snr in db

M = 4; % order of modulation
n = log2(M); % no. of bits per symbol

% chan = rayleighchan(sampling_time,200);
% chan.resetbeforefiltering = 0;
ber_final = zeros(1,length(SNR));
no_of_symbols = 100;
%chan.resetbeforefiltering =0;
for i = 1:length(SNR)
i
test_1 = [];
test_2 = [];
errors_new = 0;
for j=1:no_of_symbols
x_user = floor(M*rand(N_data,1));
test_1 = [test_1,x_user.'];
%x_user = floor(M*rand(Nfft,1));
X_mod_out = qammod(x_user,M).';
% subcarrier_out = subcarrier_mapping(X_mod_out.',Nfft);
% subcarrier mapping
subcarrier_out = zeros(Nfft,1);
subcarrier_out([29:40,42:65,67:90,92:115,117:128,130:141,143:166,168:191,193:216,218:229]) = X_mod_out;
% % processing information for getting timedomain waveform
% subcarrier_out = X_mod_out;
x_out = tx_sub_part(subcarrier_out,Nfft);
x_ofdm_symbol = [x_out(Nfft-N_prefix+1:end),x_out].';

% channel generation and passing the signal through fading channel

%chan = rayleighchan(sampling_time,2,[0,1.5e-5,3.2e-5],[0,-3,-3]);

%chan.StoreHistory = 0;
chan = rayleighchan(sampling_time,100);
%chan = rayleighchan(sampling_time,10,[0,Tg/4],[0,-20]);
% chan.resetbeforefiltering = 0;
%chan = ricianchan(sampling_time,4,[0,Tg/10],[0,-9],10);

gain_c = chan.pathgains;
Gain_c = fft(gain_c,Nfft).';

% pasing signal through awgn channel

% removing the cycling prefix part
% it is also known as synchronisation part
% here perfect synchronisation is assued

% one tap equalizer is implimented below

r_out = rx_sub_part(eq_out.',Nfft);

%demap_out = subcarrier_demap(r_out);
% getting information symbols by subcarrier demapping
demap_out = r_out([29:40,42:65,67:90,92:115,117:128,130:141,143:166,168:191,193:216,218:229]);

%demap_out = r_out;

% demodulation of the signal
x_cap = qamdemod(demap_out,M);
test_2 = [test_2,x_cap.'];

%[ no_of_errors,BER ] = biterr(x_cap,x_user);

%errors_new = errors_new + no_of_errors;
end
[ no_of_errors,BER(i) ] = biterr(test_1,test_2);
%ber_final(i) = errors_new/(N_data*no_of_symbols);
end

semilogy(SNR,BER);
xlabel('SNR in dB');
ylabel('BER Values');
title('SNR Vs BER plot');

% this programme is for subpart of the transmitter...
% input--> Xin : out put of modulator
% Nfft : FFT size
% output--> x_out : time domain version ( 1xNfft )

function [x_out] = tx_sub_part(Xin,Nfft)

[x_out] = ifft(Xin.',Nfft);
end

% this function is for implimenting the subpart of the receiver
% input--> r_in : output of the channel
% Nfft : FFT size
% output--> R_out : frequency domain version of the received signal
% (1xNfft)

function [R_out] = rx_sub_part(r_in,Nfft)
[R_out] = fft(r_in.',Nfft);
end

<---------------------------********************---------------------------------->

thanx regards..
uday

amyeka

### amyeka

Points: 2

#### srithesaint

##### Newbie level 1

to any one still active in this topic....

can u explain me how the rayleigh fading simulation in Rappaport book sec [5.72] working. please explain me how the method of rayleigh fading simulation working. i don't understand the part saying generate complex gaussian random variables for each N/2 positive frequency. why do we need to do N/2?

how to assign these noise to frequancy components?

i have the max doppler freq 200Hz, sampling period 2 seconds, number of samples 10001

please give example of coding for this methods....i need it urgently thank you

#### patriot100

##### Newbie level 1
tap delay line

Hi vuday
could you find any explanation of your code? if so, can you explain it us, too?

#### Sherra

##### Member level 3

Hi Vuday!!

Hi all,
is anyone still active in this post???

Find it intersting, as i am working on multipath channels in OFDM, i was just wondering how i could change this code to include delays..could ANYONE PLEASE just give me directions..?
Also, WHEN I HAVE TO INCLUDE DELAYS, during the equalization part i think i will have to FFT not only the gain but the channel object (chan) and divide it to the noisy data.. am i right?

could u pls anyone explain me how can i use the 'rayleighchan' function in loop for simulation of ofdm system..

i passed the say 100 symbols through this rayleighchan function and i added indivually awgn ...then after demodulation i ploted the ber curve.

i am appending my code..is my code is correct..pls correct it if any wrong..

and also pls let me know abt how can i modify the code for working in case of varying dopler frequency..

<-----------------------------**********************------------------------------->

% ofdm system design ...

% BW = input('enter the channel bandwidth :');
% Nused = input('enter the number of subcarriers :');
% n_factor = input('enter the sampling factor :');
% G = input('enter the ration of CP time to Useful time :');
clear all
close all
clc
BW = 1.75e6;
Nused = 200;
n_factor = 8/7;
G = 1/4;

[Nfft,Fs,delta_f,Tb,Tg,Ts,sampling_time] = derived_parameters(BW,Nused,n_factor,G);

% Nfft-->fft size , Fs-->sampling frequency , delta_f-->suhcarrier spacing
% Tb--> useful symbol time, Tg-->guard/CP time, Ts-->OFDM Symbol
% time (Tb+Tg)
N_prefix = Nfft*G;
N_data = 192;
N_pilot = 8;
SNR = 0:2:20; % snr in db

M = 4; % order of modulation
n = log2(M); % no. of bits per symbol

% chan = rayleighchan(sampling_time,200);
% chan.resetbeforefiltering = 0;
ber_final = zeros(1,length(SNR));
no_of_symbols = 100;
%chan.resetbeforefiltering =0;
for i = 1:length(SNR)
i
test_1 = [];
test_2 = [];
errors_new = 0;
for j=1:no_of_symbols
x_user = floor(M*rand(N_data,1));
test_1 = [test_1,x_user.'];
%x_user = floor(M*rand(Nfft,1));
X_mod_out = qammod(x_user,M).';
% subcarrier_out = subcarrier_mapping(X_mod_out.',Nfft);
% subcarrier mapping
subcarrier_out = zeros(Nfft,1);
subcarrier_out([29:40,42:65,67:90,92:115,117:128,130:141,143:166,168:191,193:216,218:229]) = X_mod_out;
% % processing information for getting timedomain waveform
% subcarrier_out = X_mod_out;
x_out = tx_sub_part(subcarrier_out,Nfft);
x_ofdm_symbol = [x_out(Nfft-N_prefix+1:end),x_out].';

% channel generation and passing the signal through fading channel

%chan = rayleighchan(sampling_time,2,[0,1.5e-5,3.2e-5],[0,-3,-3]);

%chan.StoreHistory = 0;
chan = rayleighchan(sampling_time,100);
%chan = rayleighchan(sampling_time,10,[0,Tg/4],[0,-20]);
% chan.resetbeforefiltering = 0;
%chan = ricianchan(sampling_time,4,[0,Tg/10],[0,-9],10);

gain_c = chan.pathgains;
Gain_c = fft(gain_c,Nfft).';

% pasing signal through awgn channel

% removing the cycling prefix part
% it is also known as synchronisation part
% here perfect synchronisation is assued

% one tap equalizer is implimented below

r_out = rx_sub_part(eq_out.',Nfft);

%demap_out = subcarrier_demap(r_out);
% getting information symbols by subcarrier demapping
demap_out = r_out([29:40,42:65,67:90,92:115,117:128,130:141,143:166,168:191,193:216,218:229]);

%demap_out = r_out;

% demodulation of the signal
x_cap = qamdemod(demap_out,M);
test_2 = [test_2,x_cap.'];

%[ no_of_errors,BER ] = biterr(x_cap,x_user);

%errors_new = errors_new + no_of_errors;
end
[ no_of_errors,BER(i) ] = biterr(test_1,test_2);
%ber_final(i) = errors_new/(N_data*no_of_symbols);
end

semilogy(SNR,BER);
xlabel('SNR in dB');
ylabel('BER Values');
title('SNR Vs BER plot');

% this programme is for subpart of the transmitter...
% input--> Xin : out put of modulator
% Nfft : FFT size
% output--> x_out : time domain version ( 1xNfft )

function [x_out] = tx_sub_part(Xin,Nfft)

[x_out] = ifft(Xin.',Nfft);
end

% this function is for implimenting the subpart of the receiver
% input--> r_in : output of the channel
% Nfft : FFT size
% output--> R_out : frequency domain version of the received signal
% (1xNfft)

function [R_out] = rx_sub_part(r_in,Nfft)
[R_out] = fft(r_in.',Nfft);
end

<---------------------------********************---------------------------------->

thanx regards..
uday

---------- Post added at 23:38 ---------- Previous post was at 22:55 ----------

Hi again, was trying to simulate but the function "derived_parameter" is missing..., where is the function "derived_parameter" what does it do exactly?

#### Ahmed Alaa

##### Full Member level 5
Check Rayleighchan function in MATLAB. You can select the number of paths, path gains and delays.

Status
Not open for further replies.