electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

Matlab Rayleigh Fading Channel Simulation?


Post new topic  Reply to topic    EDAboard.com Forum Index -> Digital communication -> Matlab Rayleigh Fading Channel Simulation?
Author Message
davyzhu



Joined: 23 May 2004
Posts: 521
Helped: 3
Location: oriental


Post06 Mar 2006 10:19   

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
Back to top
manasiri



Joined: 01 Mar 2006
Posts: 234
Helped: 16


Post07 Mar 2006 12:46   

rayleigh channel matlab


Dear sir,

I think that the answer of your problrm is in the following link

Enjoy it.

best regards

http://www.mathworks.com/matlabcentral/fileexchange/loadFileList.do
Back to top
mehtesham



Joined: 14 Nov 2005
Posts: 111
Helped: 12


Post12 Mar 2006 22:09   

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
Back to top
davyzhu



Joined: 23 May 2004
Posts: 521
Helped: 3
Location: oriental


Post13 Mar 2006 5:07   

rayleigh fading channel matlab


Hi mehtesham,

Thank you Smile

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
Back to top
Google
AdSense
Google Adsense




Post13 Mar 2006 5:07   

Ads




Back to top
carpa



Joined: 12 Nov 2004
Posts: 78
Helped: 5


Post13 Mar 2006 7:32   

rayleigh channel matlab code


You need filter the output by a digital filter.
Back to top
ssstar



Joined: 13 Oct 2004
Posts: 16


Post13 Mar 2006 15:03   

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.
Back to top
davyzhu



Joined: 23 May 2004
Posts: 521
Helped: 3
Location: oriental


Post13 Mar 2006 15:43   

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?
Back to top
mehtesham



Joined: 14 Nov 2005
Posts: 111
Helped: 12


Post14 Mar 2006 9:40   

rayleigh channel in matlab


see this paper:

http://web.mit.edu/lizhong/www/publications/tradeoff.pdf
Back to top
mimomod



Joined: 25 Jan 2006
Posts: 109
Helped: 15


Post18 Mar 2006 23:48   

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
Back to top
wee



Joined: 07 Nov 2005
Posts: 29


Post19 Mar 2006 12:17   

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.
Back to top
lincolndsp



Joined: 13 Aug 2005
Posts: 209
Helped: 3
Location: Ukraine


Post25 Aug 2006 8:09   

fading channel simulation


mimomod wrote:
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 wrote:
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?
Back to top
Noo10



Joined: 02 Sep 2006
Posts: 7


Post02 Sep 2006 16:24   

rayleigh fading channel simulation


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

Thanks in Advance
Back to top
dalysk



Joined: 30 Oct 2006
Posts: 6


Post29 Jan 2007 14:28   

rayleigh fading in matlab


see this site :
http://www.faqs.org/docs/sp/sp-1.html
Back to top
amihomo



Joined: 09 Jan 2007
Posts: 206
Helped: 23
Location: Tehran,Iran


Post31 Jan 2007 6:39   

simuation of fast fading channel mat lab


davyzhu wrote:
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
Back to top
gr8_halem



Joined: 31 Jan 2007
Posts: 6


Post31 Jan 2007 7:05   

flat fading channel matlab


may u try this;

chan=rayleighchan;
msx_rx=filter(chan,msg_mod);
msg_noise(z,Smile=(msg_rx);
end
Back to top
changfa



Joined: 14 Dec 2005
Posts: 276
Helped: 82


Post04 Feb 2007 4:49   

rayleigh channel in matlab code


davyzhu wrote:
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. )
Back to top
waqasbukhari



Joined: 04 Feb 2007
Posts: 5


Post05 Feb 2007 0:21   

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 = [0Sad1/Fs)SadM-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,Smile.*cos(theta(i,Smile));

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

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
Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> Digital communication -> Matlab Rayleigh Fading Channel Simulation?
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
Rayleigh Fading Channel simulation (9)
Correlated Rayleigh Fading Channel Simulation (5)
Matlab code for Rayleigh Fading Channel (4)
Fast rayleigh fading channel program in matlab (6)
MATlab Source Code for rayleigh fading channel (1)
Matlab nakagami Fading Channel Simulation? (1)
rayleigh fading channel pdf (5)
Capacity of a Rayleigh fading channel (2)
Matlab Nakagami-m fading channel simulation....help (5)
multipath rayleigh fading channel modelling (2)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS