Correct way to simulate Rayleigh fading for indoor environments

I am trying to simulate indoor communications with all components included. But something disturbs me when it comes to Rayleigh fading part.

I am adding my rayleigh fading to the transmitted signal with that code:

rayleigh_h = 1/sqrt(2)*[randn(1, length(s_l) / OSR) + 1j * randn(1, length(s_l) / OSR)]; %Constructing rayleigh channel complex coefficients
rayleigh_h = repelem(rayleigh_h, OSR); %Coefficient repeating to apply rayleigh fading to all samples
s_l = s_l .* rayleigh_h;


s_l: the complex modulated signal

OSR: Over sampling ratio

If I need to clarify the code a bit: Every bit is being sampled by a number of samples named "Over sampling ratio". Since I want to add rayleigh fading symbol-by-symbol instead of sample-by-sample, all samples that belong to a symbol are multiplied by the rayleigh coefficient corresponding each bit.

Sorry for if the code clarification is a bit confusing.

Here is my real question.

The method I am using above obviously changing the amplitudes of the signal with multiplying the with complex gaussian coefficients at instants. However, at indoor locations, it is fairly correct to assume that mobility(speed) of the devices should be limited with the walking speed. Therefore changes with the signal, and the fading coefficients should change slowly, not that fast. I am trying to figure out how to simulate it.

Any help is appreciated. Please also advise me if I have misunderstood the concept of the rayleigh fading.

A discrete-time baseband model of a multi-propagation channel can be written as

$$y[m] = \sum_l h_l[m] x[m-l] + w[m]$$

where $l$ is the index of channel taps if the channel is modeled as a FIR $\{h_l, 0\leq l < L-1\}$. $w[m]$ is AWGN sample.

The channel tap $h_l[m] = \sum_i \alpha_i(m/W) \times \mathrm{sinc}(l-W\times\tau_i(m/W))$ where $i$ is the index of physical propagation path; $\alpha_i$ and $\tau_i$ are the gain and the delay of path $i$, respectively; $W$ is the bandwidth of signal $x(t)$.

The philosophy of this modeling is that due to the decay of $\mathrm{sinc}()$ function, $h_l[m]$ has significant contribution of the path $i$ having delay $\tau_i \in [l/W-1/2W,l/W+1/2W]$. Next the reason of Rayleigh modeling is that these number of that kind of path $i$ for $h_l$ is quite high and by the central limit theorem, $h_l$ is complex Gaussian.

The Rayleigh fading assumption is reasonable for the indoor environment because of the high number of scattering object.

The fact that you have used element-wise multiplication between s_l and rayleigh_h implies that your channel is one tap, i.e. $L=1$. One reason is that bandwidth $W \ll \textrm{delay spread } \tau_m$. Check it.

To model the fact that channel varies in time, you need to consider the notion of coherence time. The channel model you are trying to use is called Rayleigh Block fading. For a quick and dirty approach, just calculate the coherence time $T_c$ (based on the carrier frequency and the velocity), then divide it by the symbol time $1/W$ for the number of symbol that channel is assumed constant. I mean something like

nrep = OSR * Tc * W;
rayleigh_h = 1/sqrt(2)*[randn(1, length(s_l) / nrep) + 1i * randn(1, length(s_l) / nrep)];
rayleigh_h = repelem(rayleigh_h, nrep);
s_l = s_l .* rayleigh_h;

• Sorry for me forgetting to pointing out the channel is one tap. And thanks for the tremendous explanation of the fading. Thanks to you I know I am on the right path. However, the question I was trying to ask was something like this. – Furkan Küçük Oct 11 '17 at 18:03
• I am working on a bluetooth project so it is a 2.4 ghz digital channel rather than a radio channel. The question I was asking about was simply this: h is a set of random variable which is distributed with rayleigh distribution. Hence h can be 2 at the first symbol but can be 0.5 at the second symbol. However, in a relatively stable environment like indoor environment, it shouldn't change that dramatically. What I need is a different approach to adding "more smooth" h coefficients. E.g. 2 at the first symbol and 1.8 at the second symbol. – Furkan Küçük Oct 11 '17 at 18:04
• @FurkanKüçük this is related to the coherence time concept that I have mentioned in my answer. – AlexTP Oct 11 '17 at 18:07

Your question is quite unclear, but it seems like you're trying to simulate the continuous-time radio channel. In this model, you do not multiply by complex coefficients; rather, you add delayed and attenuated copies of the transmitted signal.

Say you transmit $s(t)$. Then, the received signal is $$r(t)=\sum_k g_k s(t-\tau_k) + n(t),$$ where $g_k$ is the gain of each path and $\tau_k$ is the delay along that path. Your indoor channel model should provide a framework for generating the gains and delay for simulation. $n(t)$ is white noise.

In the discrete-time channel model, you don't care about how the signal looks in the air; all you care about is the samples at the output of the matched filter. It turns out that if the number if paths is large, and if the delays and gains meet certain statistical conditions, and furthermore assume that the receiver is synchronized, then the matched filter samples have the form $$r=hs+n,$$ where $s$ is one transmitted symbol, $n$ is a sample from a Gaussian random variable, and $h$ is the channel gain, a complex number with Gaussian real and imaginary parts. This is known as flat Rayleigh fading (AlexTP's answer covers the more general case of frequency-selective fading).

You're right in assuming that mobility speed (either of the transmitter, receiver, or reflectors) will affect the channel. In the discrete-time model, a slow fading channel is one where $h$ remains constant for several symbol durations. In the continuous channel, this means that the paths the signal takes between transmitter and receiver stay constant for several symbol times.

Edited to add: How to generate the channel gains $h$ is the subject of a lot of literature, and it can get quite complicated. The simplest approach is this: assume a channel coherence time, or equivalently, a number of symbols that will be subject to the same $h$. After that, generate a new $h$ independently from the previous one. Many researchers (me included) take this approach, which is valid as a first approximation to the real, physical problem.

• Sorry for the unclear question. I did my best to keep my question clear and yet giving you the necessary parts of the code I had written to give you an idea. – Furkan Küçük Oct 11 '17 at 17:52
• I am working on a bluetooth project so it is a 2.4 ghz digital channel rather than a radio channel. The question I was asking about was simply this: h is a set of random variable which is distributed with rayleigh distribution. Hence h can be 2 at the first symbol but can be 0.5 at the second symbol. However, in a relatively stable environment like indoor, it shouldn't change that dramatically. That gives me the idea that I do something wrong with the adding rayleigh channel effect. Maybe convolving or integrating should do the work? – Furkan Küçük Oct 11 '17 at 17:56
• @FurkanKüçük I've added a bit of extra information regarding your question. – MBaz Oct 11 '17 at 20:58