Continue to Site

# Matlab Rayleigh Fading Channel Simulation?

Status
Not open for further replies.

#### davyzhu

Hi all,

I have got a Rayleigh Fading Channel Simulation code by Matlab.

The code list below:
a = sqrt(0.5)*( randn( 1, symbols_per_frame) + j*randn( 1, symbols_per_frame) );
% complex noise
noise = sqrt(variance)*( randn(1,symbols_per_frame) + j*randn(1,symbols_per_frame) );
% in all

Is the code right? If not right, how to modify it?

Best regards,
Davy

rayleigh channel matlab

Dear sir,

Enjoy it.

best regards

matlab rayleigh channel

but in some simulation i did:

a = randn( 1, symbols_per_frame) + j*randn( 1, symbols_per_frame) ;

% complex noise

noise = randn(1,symbols_per_frame) + j*randn(1,symbols_per_frame) ;

% in all

Nt is number of Tx antenna

Hi mehtesham,

Thank you

I am confused with your formular. If Nt increase, sqrt(SNR/Nt) will decrease?
BTW, code I got is SNR/Nt=0.5. Does it mean normalize?

Best regards,
Davy

rayleigh channel matlab code

You need filter the output by a digital filter.

phase ditortion channel+matlab

I am sorry to tell you。
I don't think you are right.
because it is very not accurent, you must know randn() is not very stable.

I suggest that you should look at the papers of Clark,Jakes, and C.xiao.
there are three ways to model Rayleight channel, which are IDFT/WSS/AR.
if you just play , forget it.

frequency selective channel matlab

Hi,

I have read the Probability book. The phase shift is uniformly distribution. And the fading is Rayleigh distribution.

I am interested in paper about Rayleigh channel.

But what's IDFT/WSS/AR mean?

rayleigh channel in matlab

see this paper:

nakagami distribution matlab

Hi davyzhu,

the matlab codes you wrote are basically right. Off course others could argue that the randn() function is not stable or how to define the right power, etc. But basically, it is right.

But.....when I read your codes I found out that the codes are a little strange for simulating wireless channels. First, the codes generated different fading for each symbol. This happens rarely in practice since the channel will be more or less constant for several symbols, otherwise we have much difficulties to do signal processing at the receiver to get the original data back.

best

simulation rayleigh channel

Hi all,

I am sorry if i got this wrong.

For Multipath fading, can i simply add a tau difference to the orignating signal and then use randn function to create an awgn environment?

(*Sorry for the highjacked*)

Thank you.

Regards.

mimomod said:
Hi davyzhu,

the matlab codes you wrote are basically right. Off course others could argue that the randn() function is not stable or how to define the right power, etc. But basically, it is right.

But.....when I read your codes I found out that the codes are a little strange for simulating wireless channels. First, the codes generated different fading for each symbol. This happens rarely in practice since the channel will be more or less constant for several symbols, otherwise we have much difficulties to do signal processing at the receiver to get the original data back.

What changes should be made to fix this problem

mimomod said:
First, the codes generated different fading for each symbol. This happens rarely in practice since the channel will be more or less constant for several symbols

And is the original code multiplied by Rayleigh fading is a passband signal
or baseband?

hi all
I want to genarte wireless source code for matlab Ka...

simuation of fast fading channel mat lab

davyzhu said:
Hi all,

I have got a Rayleigh Fading Channel Simulation code by Matlab.

The code list below:
a = sqrt(0.5)*( randn( 1, symbols_per_frame) + j*randn( 1, symbols_per_frame) );
% complex noise
noise = sqrt(variance)*( randn(1,symbols_per_frame) + j*randn(1,symbols_per_frame) );
% in all

Is the code right? If not right, how to modify it?

Best regards,
Davy

hi,

essentialy the fading process has two effects :
1)a phase distortion which is modeled as a uniform R.V in the interval [-Π,Π]
2)a push distortion which is modeled as a rayleigh , rice , nakagami , ... distribution.

in simulation we assume that the phase distortion in completeley compensated in the receiver and only analyze the effect of push distortion .

based on the above , your code seems to be correct.

regards

may u try this;

chan=rayleighchan;
msx_rx=filter(chan,msg_mod);
msg_noise(z,=(msg_rx);
end

rayleigh channel in matlab code

davyzhu said:
Hi all,

I have got a Rayleigh Fading Channel Simulation code by Matlab.

The code list below:
a = sqrt(0.5)*( randn( 1, symbols_per_frame) + j*randn( 1, symbols_per_frame) );
% complex noise
noise = sqrt(variance)*( randn(1,symbols_per_frame) + j*randn(1,symbols_per_frame) );
% in all

Is the code right? If not right, how to modify it?

Best regards,
Davy

The codes are no problem, but the physical meaning behind them is another story.

As one friend pointed out, your channel changes so fast in time domain that every symbol experiences independent fading. This is rare in reality because system designer want the TX/RX simple and rarely choose such operating point. A simple model is block-fading channel. To model this, you need to know the coherence time of the channel as well as your symbol duration, then you know how many symbols can be assumed experieceing same channel coefficients. For different block, channel is independent.

(For more accurate channel, you need to take Doppler spectrum into account. Doppler spectrum determines how fast your channel is evolved in time. To simulate this, generally a filtering is done. )

matlab code for rayleigh channel

following is the relevant code which i have used in my simulations in one of the projects "design and optimization of cooperative diversity in wireless sensor networks"

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 = [01/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

%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

davyzhu said:
...
a = sqrt(0.5)*( randn( 1, symbols_per_frame) + j*randn( 1, symbols_per_frame) );
...

Why is this 0.5 factor?

can any one share complete rayleigh fading channel for indoor communication with multiple users.
please share here, mathworks i get confuse.

i need complex rayleigh for ten antennas is this procedure right
for n=1:10;
G3=randn((2*n),M);
G4=randn((2*n),M);

bb=0;
RR=zeros(n,M);

for ii=1:2:2*n;
bb=bb+1;
Rr=abs(G3(ii,+1i*G3(ii+1,); % Rayleigh fading hnk, 10x100
Ri=abs(G4(ii,+1i*G4(ii+1,);
yy=(1/sqrt(2))*(Rr+1*j*Ri);% complex Rayleigh fading hnk, 10x100
% yy=G3(ii+1)+1i*G4(ii+1,;
hnk(bb,=yy;
end

Status
Not open for further replies.