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 Fading in Matlab.

Status
Not open for further replies.

malaylah

Junior Member level 1
Joined
Feb 27, 2005
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,452
rayleigh fading matlab

Anyone here know how to generate rayleigh distribution(rayleigh fading) in Matlab?For Gaussian, it is very simple as randn(x).How about for very basic Rayleigh?I mean without cosider doppler frequency and etc.
 

rayleigh distribution matlab

If you do not care about doppler.That is if you do not do channel estimation, and other effects.

Rayleigh can be generated by

R=randn(N,1)+sqrt(-1)*randn(N,1);
and the envelope is distruibuted according to rayleigh as

r=abs(R)
 

rayleigh matlab

Code:
% Program to simulate Rayleigh fading using a p-th order autoregressive model AR(p) according to 
% Baddour's work: "Autoregressive modeling for fading channel simulation", IEEE Transaction on Wireless Communications, July 2005.

function [chann]=Rayleigh_fading(P,M,fm,fs,epselonn)
    % P: AR model order
    % M: number of samples
    % fd: maximum doppler frequency in Hz
    % fs: Symbol frequency in ksps
    % epselonn: added bias, depends on the Doppler rate, see the paper "Autoregressive modeling for fading channel simulation". 
   
    % usage: Rayleigh_fading(100,10000,150,3,0.00000001)
    
   
    %-------------------------------------------------------------------------------------------------------------------------   
     
        for p=1:P+1
          vector_corr(p)=besselj(0,2*pi*fm*(p-1)/(fs*1000)); % Bessel autocorrelation function according to Jakes' model
        end
        
        auto_correaltion_matrix=toeplitz(vector_corr(1:P))+eye(P)*epselonn; % adding a small bias, epselonn, to the autocorrelation matrix to overcome the ill conditioning of Yule-Walker equations
        AR_parameters=-inv(auto_correaltion_matrix)*vector_corr(2:P+1)'; % Solving the Yule-Walker equations to obtain the model parameters
        segma_u=auto_correaltion_matrix(1,1)+vector_corr(2:P+1)*AR_parameters;
        
        KKK=2000;
   
        h=filter(1,[1 AR_parameters.'],wgn(M+KKK,1,10*log10(segma_u),'complex')); % Use the function Filter to generate the channel coefficients
        chann=h(KKK+1:end,:);  % Ignore the first KKK samples
         
    %-------------------------------------------------------------------------------------------------------------------------

From h**p://www.mathworks.com/matlabcentral/
:D
 

rayleigh fading channel matlab

malaylah said:
Anyone here know how to generate rayleigh distribution(rayleigh fading) in Matlab?For Gaussian, it is very simple as randn(x).How about for very basic Rayleigh?I mean without cosider doppler frequency and etc.
you can use this instruction"raylpdf" or "pdf('rayleigh',)"
 

matlab rayleigh

janath said:
If you do not care about doppler.That is if you do not do channel estimation, and other effects.

Rayleigh can be generated by

R=randn(N,1)+sqrt(-1)*randn(N,1);
and the envelope is distruibuted according to rayleigh as

r=abs(R)

How is then the phase of the fading generated and
how to take into account when modelling the flat slow fading
the speed of fading, the delay. Please could anyone post the matlab code
taking into account my questions?
 

jakes model matlab

lincolndsp said:
janath said:
If you do not care about doppler.That is if you do not do channel estimation, and other effects.

Rayleigh can be generated by

R=randn(N,1)+sqrt(-1)*randn(N,1);
and the envelope is distruibuted according to rayleigh as

r=abs(R)

How is then the phase of the fading generated and
how to take into account when modelling the flat slow fading
the speed of fading, the delay. Please could anyone post the matlab code
taking into account my questions?

System.out has posted the code for generating a rayleigh fading process related doppler frequency. You need to deside the value of fm,fs,etc. To determine whether the fading is slow or fast varying, you need to set the ratio of fm to fs.
 

matlab rayleigh distribution

what is the range of ratios of fm and fs for
slow flat fading

and how to apply channel coefficients obtained using
the code provided by System.out to get the resulting
fading signal. I mean I have the input signal s and
channel coefficients, how do i get the resulting fading
signal, say, r
 

rayleigh fading channel matlab code

another article about raleigh fading
 

fading channel matlab

i want to know about simple fast rayleigh fading channel program in matlab..is anyone knows about it? i just want to make it as my reference, so that i can learn fast rayleigh fading channel from that program...

thak you
 

matlab rayleigh fading

this is how i used it in my UG project when dealing with a case of flat fading .



%function flatfading

clear;



N =100; %Enter the number of random scaterers

M =1000 %Enter the no of realizations



A = 1 %Enter the value of A

fc =1000; %carrier frequency

Fs=4000; %sampling frequency greater than Nyquist rate

w = 2 * pi * fc ;



t = [0:(1/Fs):(M-1)*(1/Fs)];

L=length(t);



theta = (rand(N,1) * 2 * pi) - pi;

Ak = (rand(N,1) * 2) - 1;



X = zeros(1,L) ;

for m = 1:N

X=X+Ak(m)*cos(w.*t+theta(m));

end

% Analyzing that X(t) is a narrow-band spectral process

Y = fft(X) ;

Y = fftshift(Y) ;



plot(abs(Y)) ;

title( 'Magnitude of fft of a single realisation of X(t)') ;

xlabel( 'Frequency' ) ;

ylabel( 'Magnitude' ) ;

pause

%Calculating XI and XQ

Ak = (rand(N,M) * 2 ) - 1;

theta = (rand(N,M) * 2 * pi) - pi;





XI = zeros(1,M ) ;

XQ = zeros(1,M ) ;

for i=1:N



XI = XI+(Ak(i,:).*cos(theta(i,:)));

XQ = XQ+(Ak(i,:).*sin(theta(i,:)));

end

%Calculating the central moments and beta values for in and quadrature phase



U2_inphase = moment(XI,2);

U3_inphase = moment(XI,3);

U4_inphase = moment(XI,4);



B1_inphase = (U3_inphase)^2/(U2_inphase)^3

B2_inphase = (U4_inphase)/(U2_inphase)^2



U2_quad = moment (XQ,2);

U3_quad = moment (XQ,3);

U4_quad = moment (XQ,4);



B1_quad = (U3_quad)^2/(U2_quad)^3

B2_quad = (U4_quad)/(U2_quad)^2



%Calculating the envelope r from the M realisations of XI and XQ



r = sqrt(XI .^ 2 + XQ .^ 2);

phi = atan(XQ ./ XI);



R=hist(r,100);

index = 1:100 ;



R_index = (index/length(index)*ceil( max(r)));

stem(R_index,R)

title( 'Histogram of distribution of the Envelope R' ) ;

xlabel('R') ;

ylabel('Frequency of R' ) ;

pause





% including line of sight component

for a = 0:5



XL = a*cos(2*pi*fc*t);



XI_2 = XI + XL;



r = sqrt(XI_2 .^ 2 + XQ .^ 2);



R = hist(r,100);

index = 1:100 ;



R_index = (index/length(index)*ceil( max(r)));



subplot( 2, 3,(a +1));

plot(R_index,R)



end
 

rayleigh channel matlab code

this is the way i used rayleigh flat fading.....
divide the data in small frames and then convolve it with the h, where h = (randn(1) + j*randn(1))/sqrt(2);
the value of h will be diff for each frame.
It a flat fadding in the sence that the value of channel remains constant over the time(here frame)

correct me if i am wrong.
 

rayleigh fading in matlab

To generate a Rayleigh fading channel model, you first generate real and image part of the independent Gaussian process, then you need design a filter to have the spretrum similar to Jakes model, i.e, to have the Bessel function as the auto-correlation. Passing through the I, Q Gaussian process to this filter, you oculd get the Rayleigh fadung model.
 

rayleigh channel in matlab

The cdf of rayleigh distribution is

F(r) = 1 - exp(-r^2/2sigma^2)

r = sqrt(-2sigma^2 * ln(1-F(r))

In the matlab code, i set 2sigma^2 = 1 so

r = sqrt(-log(rand(1,N)));

receive_signal = transmit_signal.*r + awgn;

Not sure whether it is correct?
 

Re: rayleigh channel in matlab

The cdf of rayleigh distribution is

F(r) = 1 - exp(-r^2/2sigma^2)

r = sqrt(-2sigma^2 * ln(1-F(r))

In the matlab code, i set 2sigma^2 = 1 so

r = sqrt(-log(rand(1,N)));

receive_signal = transmit_signal.*r + awgn;

Not sure whether it is correct?




Hi,
I tried to implement Rayleigh channel with the same Principe, but the system give me this error:

??? Error using ==> mtimes
Inner matrix dimensions must agree.

Error in ==> canal16 at 13
demodulator_output=Rl*modulator_output+sigma*(randn(1,T)+j*randn(1,T));
Error in ==> test5 at 125
demodulator_output=canal16(demodulator_output);
--------------------------------------------
this is the block programmed

function demodulator_output=canal16(modulator_output);

global sigma T

comp1=(1/sqrt(2))*randn(1,T);
comp2=(1/sqrt(2))*randn(1,T);

% variable aleatoire rayleigh

%RL=sqrt(square(comp1)+square(comp2));
Rl=sqrt((comp1.^2+comp2.^2));

demodulator_output=Rl*modulator_output+sigma*(randn(1,T)+j*randn(1,T));

can you please tell me how to define the inner matrix dimension?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top