% 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
%-------------------------------------------------------------------------------------------------------------------------
you can use this instruction"raylpdf" or "pdf('rayleigh',)"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.
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)
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?
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?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?