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.

Matlab Rayleigh Fading Channel Simulation?

Status
Not open for further replies.

davyzhu

Advanced Member level 1
Joined
May 23, 2004
Messages
494
Helped
5
Reputation
10
Reaction score
2
Trophy points
1,298
Location
oriental
Activity points
4,436
rayleigh fading matlab

Hi all,

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

The code list below:
% Rayleigh fading
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
code_fade = a.*code + noise;

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

Best regards,
Davy
 

mehtesham

Junior Member level 3
Joined
Nov 14, 2005
Messages
31
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Activity points
1,551
matlab rayleigh channel

your code can be correct.

but in some simulation i did:

% Rayleigh fading

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

code_fade = sqrt(SNR/Nt)*a.*code_mod + noise;

Nt is number of Tx antenna
 

davyzhu

Advanced Member level 1
Joined
May 23, 2004
Messages
494
Helped
5
Reputation
10
Reaction score
2
Trophy points
1,298
Location
oriental
Activity points
4,436
rayleigh fading channel matlab

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
 

carpa

Member level 3
Joined
Nov 12, 2004
Messages
56
Helped
6
Reputation
12
Reaction score
3
Trophy points
1,288
Activity points
481
rayleigh channel matlab code

You need filter the output by a digital filter.
 

ssstar

Junior Member level 1
Joined
Oct 13, 2004
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
136
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.
 

davyzhu

Advanced Member level 1
Joined
May 23, 2004
Messages
494
Helped
5
Reputation
10
Reaction score
2
Trophy points
1,298
Location
oriental
Activity points
4,436
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?
 

mimomod

Member level 4
Joined
Jan 25, 2006
Messages
77
Helped
22
Reputation
44
Reaction score
7
Trophy points
1,288
Activity points
2,351
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.

Secondly, the codes generated flat fading channel (more accurately, varying flat fading channel). This fading is the simplest fading in wireless environment. More widely used model is frequency selective fading channel, where you generate a kind of filter with its coefficients are the realizations of flat fading channel as generated by your codes. Better, thus more realistic, you take into account the Doppler effect for fading channel due to movement of TX and/or RX. This generation of fading channel needs more sound knowledge on statistics. You could see the book by Paetzold on fading channels. The book was uploaded in this forum, but sorry that I forget where to find.

best
 

wee

Junior Member level 2
Joined
Nov 7, 2005
Messages
24
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,494
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*)

Please advice.

Thank you.

Regards.
 

lincolndsp

Banned
Joined
Aug 13, 2005
Messages
71
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,288
Location
Ukraine
Activity points
0
fading channel simulation

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.

Secondly, the codes generated flat fading channel (more accurately, varying flat fading channel). This fading is the simplest fading in wireless environment. More widely used model is frequency selective fading channel, where you generate a kind of filter with its coefficients are the realizations of flat fading channel as generated by your codes. Better, thus more realistic, you take into account the Doppler effect for fading channel due to movement of TX and/or RX. This generation of fading channel needs more sound knowledge on statistics. You could see the book by Paetzold on fading channels. The book was uploaded in this forum, but sorry that I forget where to find.

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?
 

Noo10

Newbie level 4
Joined
Sep 2, 2006
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,311
rayleigh fading channel simulation

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

Thanks in Advance
 

amihomo

Full Member level 5
Joined
Jan 9, 2007
Messages
285
Helped
66
Reputation
132
Reaction score
42
Trophy points
1,318
Location
PERSIAN Gulf
Activity points
3,108
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:
% Rayleigh fading
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
code_fade = a.*code + noise;

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
 

gr8_halem

Newbie level 4
Joined
Jan 31, 2007
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,321
flat fading channel matlab

may u try this;

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

changfa

Advanced Member level 4
Joined
Dec 14, 2005
Messages
119
Helped
21
Reputation
42
Reaction score
6
Trophy points
1,298
Activity points
2,124
rayleigh channel in matlab code

davyzhu said:
Hi all,

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

The code list below:
% Rayleigh fading
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
code_fade = a.*code + noise;

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

waqasbukhari

Newbie level 4
Joined
Feb 4, 2007
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,346
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"



%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
 

saeddawoud

Full Member level 3
Joined
Apr 27, 2007
Messages
159
Helped
6
Reputation
12
Reaction score
1
Trophy points
1,298
Activity points
2,166
Re: rayleigh fading matlab

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

Why is this 0.5 factor?
 

tamoor

Newbie level 6
Joined
Apr 5, 2011
Messages
13
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,342
can any one share complete rayleigh fading channel for indoor communication with multiple users.
please share here, mathworks i get confuse.


please, thank you
 

abeerawad

Newbie level 2
Joined
Feb 28, 2011
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,292
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.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top