0% found this document useful (0 votes)
5 views

Mat Lab Book

Uploaded by

Apache Mungus
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Mat Lab Book

Uploaded by

Apache Mungus
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

1

1. Introdution
Matlab is very powerful program which has been applied in many areas such as mobile
communications. In over the world, Matlab has been used not only in academic educations
but also in industrial applications.
This script helps students understand fundamental principles of mobile communication
and deverlope their Matlab programming skill.

2. Descriptions of excercises
• Exercise 1: Theoretical calculation and simulation of a Gaussian distributed random
variable.
• Exercise 2: Calculation of autocorrelation, power spectral density dunction, Rice
distribution function.
• Exercise 3: Calculation of the level crossing rate (LCR) and average duration of
fading (ADF) of Rice processes. Calculation of Nakagami distribution.
• Exercise 4: Channel modelling by using Rice method.
• Exercise 5: Modulation and demodulation of the QPSK signal.
• Exercise 6: Bit error probability of QPSK on a AWGN and a fading channel.
• Exercise 7: Bit error probability of QPSK with convolutional code on a fading
channel.
• Exercise 8: Symbol error ratio of an OFDM system.

4. References
1) Kermit Sigmon, MATLAB Primer, Second Edition, Department of Mathematics,
University of Florida, 1992.
2) MATHWORKS Inc, MATLAB High-Performance Numeric Computation and Visu-
alization Software, User’s Guide, South Natick, MA, USA, 1994.
3) www.mathwork.com.
4) Proakis, J.G. Digital Communications, 3. edition, New York: McGraw-Hill, 1995.
5) Paetzold, M. Mobilfunkkanaele, Germany: Vieweg & Sohn Verlag GmbH, 1999.
2

Exercise 1
1.1 The probability density function (PDF) of a Gaussian distributed ran-
dom variable µ is given by
1 (x − mµ )2
pµ (x) = √ exp [− ], (1.1)
2πσµ 2σµ2

where mµ and σµ denote the mean value and the variance of µ, respec-
tively. For mµ = 0 and σµ = 1, sketch the PDF pµ (x) in the interval
−4 ≤ x ≤ 4. Check whether or not the PDF result is correct by using
R∞
−∞ pµ (x)dx = 1.

Hint: Use the MATLAB function trapz to compute the integral and
use for the discretization of x the MATLAB command x = −4 : 0.05 :
4.

1.2 A digital transmission system always includes some white noise which
is usually Gaussian distributed. Use the MATLAB function randn to
generate a real-valued white noise vector having a length of 1000000.
Determine the mean value, the variance (power), and the PDF of the
noise from this noise vector. Plot the PDF and compare it with the
theoretical curve in (1.1) under the condition that they have the same
mean value and variance.

Hint: Use the MATLAB functions mean, var, and hist.


3

Exercise 2
2.1 For the 2–D isotropic scattering flat fading channel model (Clarke’s
model), the autocorrelation function (ACF) of the real and imaginary
components of the received complex signal g(t) = gI (t) + jgQ (t) can
be expressed by
Ωp
φgI gI (τ ) = φgQ gQ (τ ) = J0(2πfm τ ) , (2.1)
2
where Ωp represents the total received power, fm is the maximum
Doppler frequency, and J0(·) denotes the zeroth-order Bessel function
of the first kind.

1) In GSM systems, the carrier frequency is given by fc = 900 MHz.


For a mobile station with the speed of v = 109.2 km/h, calculate
the maximum Doppler frequency fm according to
v vfc
fm = = , (2.2)
λc c0
where λc is the wavelength and c0 = 3×108 m/s denotes the speed
of light.
2) Compute the ACF φgI gI (τ ) over the interval 0 ≤ τ ≤ 0.08 s and
sketch your results. Use the value 2 for Ωp .
3) What is the value for φgI gI (0)? What is the relationship between
φgI gI (0) and Ωp.

Hint: Use the MATLAB function besselj for the calculation of the
Bessel function J0 (·).
2.2 For Clarke’s model, the power spectral density (PSD) of gI (t) and
gQ (t) can be expressed by
Ωp

√ 1


2πfm , |f | ≤ fm ,
SgI gI (f ) = SgQ gQ (f ) =  1−(f /fm)2 (2.3)
 0 , |f | > fm .
4

Calculate SgI gI (f ) and sketch it. Use the same values for Ωp and fm
as in Exercise 2.1.
2.3 If the 2–D isotropic scattering environment consists of a scattered com-
ponent plus a strong line-of-sight (LOS) component, the probability
density function (PDF) of the received signal amplitude α(t) = |g(t)|
is given by the following Rice distribution
 v 
2
2x(K + 1) (K + 1)x u K(K + 1) 
u
pα (x)= exp [−K − ]I0 2xt ,x ≥ 0. (2.4)
 u
Ωp Ωp Ωp

Here, I0(·) denotes the zeroth-order modified Bessel function of the


first kind, Ωp = E[α2(t)] = s2 + 2b0, and K denotes the Rice factor,
which is defined as the ratio of the LOS power s2 to the scattered
power 2b0, i.e., K = s2/2b0.

1) For Ωp = 1, compute pα (x) and sketch it for the following cases:


K = 0, K = 3, and K = 80.
2) When K = 0, the Rice PDF will tend to which distribution?
3) When K → ∞, the Rice PDF tends to which distribution? In
this case, does the channel still exist any fading?

Hint: Use the MATLAB function besseli for the calculation of the
modified Bessel function I0(·).
2.4 For Rice fading, the PDF of the squared envelope, i.e., α2(t) = |g(t)2 |,
is given by the following non-central chi-square distribution
 v 
K +1 (K + 1)x  u u K(K + 1)x 
u
pα2 (x) = exp [−K − ]I0 2t  , x ≥ 0 . (2.5)
Ωp Ωp Ωp

1) For Ωp = 1, compute pα2 (x) and sketch it for the following cases:
K = 0, K = 3, and K = 80.
2) When K = 0, pα2 (x) will tend to which distribution?
3) When K → ∞, pα2 (x) tends to which distribution?
5

Exercise 3
3.1 The envelope level-crossing rate (LCR) of Rice processes can be ex-
pressed as
2
q q
LR (R) = 2π(K + 1)fm ρe−K−(K+1)ρ I0 (2ρ K(K + 1)) , (3.1)

where ρ = R/ Ωp with Ωp = s2 +2b0 , and the Rice factor K = s2 /2b0.


q

For Ωp = 1, compute the normalized LCR LR (R)/fm and plot this


function for the following cases: K = 0, K = 3, and K = 10. Give
your results for the level R ∈ {0,0.05,0.1,· · ·,4.5}.

Hint: Consider R as a vector defined by r = 0 : 0.05 : 4.5, and


make use of the operations “array power” and “array multiplication”.
3.2 The average duration of fades (ADF) of Rice processes is given by
RR
P (α ≤ R) pα (x)dx
0
t(R) = = , (3.2)
LR (R) LR (R)

where pα (x) and LR (R) are given as in (2.4) and (3.1), respectively.
For Ωp = 1, compute the normalized ADF t(R) ∗ fm and plot it for
the following cases: K = 0, K = 3, and K = 10.
3.3 The Nakagami distribution is given by
2mmx2m−1 mx2 1
pα (x)= exp (− ) , m ≥ , (3.3)
Γ(m)Ωm
p Ω p 2

where Ωp = E[α2(t)], and Γ(·) denotes the Gamma function.

1) For Ωp = 1, compute pα (x) and sketch it for the following cases:


m = 1/2, m = 1, m = 4, and m = 20.
2) It is well known that the Rice distribution as shown in (2.4) can
closely be approximated by using the following relation between
the Rice factor K and the Nakagami shape factor m
6

(K + 1)2
m= . (3.4)
2K + 1
Plot these two distributions in the same figure for K = 2, i.e.,
m = 1.8, and compare the results.

Hint: Use the MATLAB function gamma for the calculation of the
Gamma function Γ(·).
7

Exercise 4

A fading channel simulator can be constructed employing Rice’s sum of


sinusoids. By using the Rice method, the complex low-pass fading signal
is in general given by

g̃(t) = g̃1 (t) + jg̃2(t) , (4.1)

where

Ni
X
g̃i (t) = ci,n cos(2πfi,nt + θi,n) , i = 1, 2 . (4.2)
n=1

The so-called Doppler coefficients ci,n , discrete Doppler frequencies fi,n,


and Doppler phases θi,n can be determined by using the method of exact
Doppler spread (MEDS) and are given in the following closed form

v
u 2b
u
ci,n = t (4.3a)
Ni
π 1
fi,n = fm sin [ (n − )] (4.3b)
2Ni 2
n
θi,n = 2π (4.3c)
Ni + 1

for all n = 1, 2, . . . , Ni and i = 1, 2, respectively. In (4.3), b is the variance


of g̃i (t), and fm denotes the maximum Doppler frequency. Note that this
simulator is of deterministic type since all the parameters are known and
kept constant during simulation. Fig. 4.1 shows the structure of the cor-
responding deterministic simulation model for Rayleigh fading channels,
where α̃(t) indicates the received signal envelope in the complex baseband.
8

c 1 ,1
co s( 2 p f 1 ,1 t + q 1 ,1 ) Ä
c
c o s( 2 p f t + q )
1 , 2
g~ 1 ( t )
1 ,2 1 ,2 Ä +
M M
c 1 ,N
c o s ( 2 p f t + q ) Ä
1

1 ,N 1 ,N

a~ ( t )
1 1

g~ ( t )
c 2 ,1
c o s ( 2 p f 2 ,1 t + q 2 ,1 ) Ä
c 2 , 2
c o s ( 2 p f t + q ) Ä +
g~
2 ,2 2 ,2

M M 2 (t)
c 2 ,N
c o s (2 p f t + q ) Ä
2

2 ,N 2 2 ,N 2

Fig. 4.1: A deterministic Rayleigh fading channel simulator.

4.1 For the given number of sinusoids N1 = 9 and N2 = 10, compute the
simulation model parameters ci,n , fi,n , and θi,n according to (4.3a)–
(4.3c) by using b = 1 and fm = 91 Hz. Write your results in Table 4.1
given on the next page.
4.2 Develop a MATLAB function m-file to simulate the deterministic
processes g̃i (t) for i = 1, 2. Use the quantities ci,n , fi,n, θi,n, and t
as input arguments.
4.3 Write a MATLAB script m-file to carry out the simulation of the
channel amplitude α̃(t) = |g̃(t)| = |g̃1 (t) + jg̃2 (t)| and plot α̃dB (t) =
20logα̃(t). Solve this problem by making use of your function m-file
developed in Exercise 4.2. The simulation model parameters ci,n , fi,n,
θi,n, and Ni are given as listed in Table 4.1. Use the simulation time
Tsim = 0.4 s and the sampling frequency fs = 270.8 kHz, which cor-
responds to the symbol rate used in GSM. If a vehicle drives with a
speed of v = 109.2 km/h, what is the distance it covers in the simu-
lation time?

Hint: The discretization of the time t can be expressed as t = 0 :


1/fs : Tsim.
9

4.4 Simulate the deterministic functions g̃1 (t), g̃(t), and α̃(t) by using the
sampling frequency fs = 50 kHz and the simulation time Tsim = 20 s.
Determine the mean value and variance of g̃1 (t), g̃(t), and α̃(t). De-
termine the probability density function (PDF) of g̃1 (t) and α̃(t) by
using histograms. Which distributions do they approximate? Com-
pare the PDF of g̃1 (t) with the theoretical result given in (1.1), where
mµ = 0 and σµ = 1. Compare the PDF of α̃(t) with the theoretical
result pα (x) given in (2.4), where Ωp = 2, and K = 0.

Hint: Use the MATLAB functions mean, std, and hist.


4.5 Determine a part of the signal g̃1(t)|t∈I from the simulation results of
g̃1 (t) in the interval I = [10 000 /fs , 20 000 /fs], where fs = 1000 Hz.
Find the autocorrelation function (ACF) φ̃g1 g1 (τ ) of g̃1(t)|t∈I and plot
it. What is the value for φ̃g1 g1 (0)?

Hint: Use the MATLAB function xcorr with the option biased.
10

i n fi,n (Hz) ci,n θi,n (rad)

1 1

1 2

1 3

1 4

1 5

1 6

1 7

1 8

1 9

2 1

2 2

2 3

2 4

2 5

2 6

2 7

2 8

2 9

2 10

Table 4.1: Parameters of the simulation model (fm = 91 Hz, b = 1, N1 = 9, N2 = 10).


11

4.6 The ACF φ̃g1 g1 (τ ) of g̃1(t) can be expressed by

N1
X c21,n
φ̃g1 g1 (τ ) = cos (2π f1,n τ ) . (4.4)
n=1 2

Compute φ̃g1 g1 (τ ) over the interval 0 ≤ τ ≤ 0.08 s and sketch your


result in the same figure as in Exercise 4.5. For the sake of comparison,
the ideal ACF φg1 g1 (τ ) in (2.1) is required to be shown in this figure
as well. Use the value 2 for Ωp and 91 Hz for fm.

4.7 Determine and sketch the power spectral density (PSD) S̃g1 g1 (f ) of
the signal g̃1 (t)|t∈I .

Hint: Use the MATLAB functions fft and fftshift. Normalize the
measured PSD to its number of spectral components.

4.8 The PSD S̃g1g1 (f ) of the simulation model is given by

N1
X c21,n
S̃g1 g1 (f ) = [δ(f − f1,n ) + δ(f + f1,n)] . (4.5)
n=1 4

Draw S̃g1 g1 (f ) in the same figure as in Exercise 4.7. Compare your


results with the ideal PSD Sg1g1 (f ) given by (2.3), where Ωp = 2 and
fm = 91 Hz.

4.9 Simulate the channel amplitude α̃(t) by using t = 0 : 1/fs : Tsim,


where fs = 10 kHz and Tsim = 10 s. Evaluate the envelope level-
crossing rate (LCR) L̃R (R).

4.10 The LCR L̃R (R) of the simulation model is given by


v
β̃ R − R2
u
u
L̃R (R) = e 2b , (4.6)
t
2π b
where
12

N1
β̃ = 2 π 2 (c1,n f1,n )2 .
X
(4.7)
n=1

Draw L̃R (R) by using b = 1 in the same figure as in Exercise 4.9.


Compare your results with the ideal LR (R) as given by (3.1), where
Ωp = 2, K = 0, and fm = 91 Hz.
13

Exercise 5
5.1 The QPSK signal constellation by using Gray encoding is shown in
Fig. 5.1. The constellation points are located symmetrically at a unit
circle in the complex domain. Then, the QPSK complex signal vectors
can be expressed by

S̃m = ejθm , m = 0, 1, 2, 3. (5.1)

where θm ∈ { π4 , 3π 5π 7π
4 , 4 , 4 }. In MATLAB, we model a binary bit se-
quence as a finite length vector. Generate a bit vector of length 50000
and then map the bits onto the complex data symbols by using QPSK
modulation with Gray encoding. Plot the constellation diagram.

Hint: Use the MATLAB function randint for generating a binary


bit sequence of “0”s and “1”s with equal probability.

0 1 0 0

1 1 1 0

Fig. 5.1: Complex signal-space diagram for QPSK with Gray encoding.

5.2 Suppose that the above modulated QPSK signals are transmitted
through an additive white Gaussian noise (AWGN) channel. Then,
the received signal is the addition of the QPSK signal and the white
Gaussian noise. First, generate a complex-valued white Gaussian noise
vector, whose length is identical with that of the QPSK signal vec-
tor. Use the value 6 dB for the signal-to-noise ratio (SNR) in decibel.
14

The SNR is defined as the ratio of the bit energy to noise power, i.e.,
SNR = Eb /N0. Plot the constellation diagram of the received signals.
You are expected to see the so-called Gaussian clouds around the orig-
inal QPSK signal points. Change the SNR (e.g., 3 dB) and plot again
the constellation diagram of the received signals.

Hint: Use the MATLAB function randn for generating Gaussian


noise.
15

Exercise 6
6.1 Let us consider a QPSK baseband transmission system as shown in
Fig. 6.1. The transmitted bits of length 100000 are mapped onto
the QPSK complex data symbols by using Gray encoding as shown
in Fig. 5.1. The modulated QPSK signals are transmitted through
an additive white Gaussian noise (AWGN) channel. We will use the
maximum likelihood (ML) receiver to detect the received signals. In
other words, we compare the distance of a received symbol to all
possible symbol values and choose the one that minimizes the distance.
After QPSK demodulation, the received bits will be compared with
the transmitted bits. Count the errors occurred during transmission
and plot the bit error probability (BEP) for the signal-to-noise ratio
(SNR) of 0, 2, 4, and 6 dB. Note that due to the long simulation
time, it is important to save the obtained simulation results by using
the MATLAB function save. The data can be retrieved by using the
function load.

A W G N

B it S o u rc e Q P S K Q P S K B it S in k
M o d u la tio n D e m o d u la tio n

B E R
C a lc u la tio n

Fig. 6.1: A QPSK transmission system over an AWGN channel.

6.2 For QPSK with Gray encoding over an AWGN channel, the theoretical
BEP pb can be obtained from
q
pb = Q( 2γb) , (6.1)
16

where Q(·) denotes the Q function and γb = Eb/N0 is the SNR. Note
that there is no Q function available in MATLAB. Fortunately, it can
be determined by using the complementary error function erfc(·) as
follows

1 x
Q(x) = erfc( √ ) . (6.2)
2 2
Compute pb and plot it for the SNR of 0, 2, 4, and 6 dB. Compare
this theoretical result with the simulated BEP in Exercise 6.1.

Hint: Use the MATLAB function erfc.


6.3 Fig. 6.2 shows a transmission chain composed of a QPSK modulator,
followed by a slow Rayleigh fading channel and a QPSK demodula-
tor. The complex fading channel coefficients are generated by using
(4.1), where ci,n and fi,n are given by (4.3a) and (4.3b), respectively.
The Doppler phases θi,n are equated with the realizations of a ran-
dom generator uniformly distributed over (0, 2π]. Other quantities
are chosen as follows: fm = 91 Hz, b = 1/2, N1 = 9, and N2 = 10.
Since the ML receiver is still used here, the receiver has the knowledge
of the complex fading coefficients. Simulate the whole transmission
system by using 500000 transmission bits and the sampling frequency
fs = 270.8 kHz. Plot the BEP for SNR = 0, 5, 10, 15, 20 dB. Remem-
ber to save the obtained simulation results.
A W G N

B it S o u rc e Q P S K R a y le ig h Q P S K B it S in k
M o d u la tio n F a d in g C h a n n e l D e m o d u la tio n

B E R
C a lc u la tio n

Fig. 6.2: A QPSK transmission chain over a Rayleigh fading channel.


17

6.4 For QPSK over a slow Rayleigh fading channel, the theoretical BEP
is expressed by
 v 
1 u γb
u
pb = 1−t  , (6.3)
2 1 + γb
where γ b = 2bEb/N0 denotes the average received SNR. For b = 1/2,
compute pb and plot it for SNR = 0, 5, 10, 15, 20 dB. Compare the
theoretical result with the simulated BEP in Exercise 6.3.
18

Exercise 7
Fig. 7.1 shows a coded QPSK baseband transmission system. The structure
of the convolutional coder with the rate Rc = 1/2 and the constraint
length K = 3 is shown in Fig. 7.2. What is the impulse response of
this convolutional coder? We assume that the encoder starts at the all-
zeros state and the decoder uses the Viterbi algorithm with hard decision.
Simulate this coding system by using 2 × 106 transmission bits and plot
the BEP for SNR = 0, 2, 4 dB. Calculate the coding gain for BEP = 10−3
with respect to the uncoded BPSK system. Note that the BEP of uncoded
BPSK is essentially the same as that of uncoded QPSK.

B it S o u rc e C o n v o lu tio n a l Q P S K
C o d e r M o d u la tio n

B E R
A W G N
C a lc u la tio n

V ite rb i Q P S K
B it S in k
D e c o d e r D e m o d u la tio n

Fig. 7.1: A coded QPSK transmission system over an AWGN channel.


19

firs t o u tp u t

in p u t o u tp u t

s e c o n d o u tp u t

Fig. 7.2: Binary convolutional encoder (Rc = 1/2, K = 3).

Hint: Use the MATLAB functions convenc, poly2trellis for the convolu-
tional coding and vitdec for the Viterbi decoding.
20

Exercise 8
8.1 Implement an Orthogonal Frequency Division Multiplexing (OFDM)
system using the following parameters taken from HIPERLAN/2 stan-
dard:

– Bandwidth of the system: B = 20 MHz,


– Sampling interval: Ta = 1/B = 50 ns,
– FFT-length: N = 64,
– OFDM symbol duration: TS = N · Ta = 3.2 µs.
– Guard interval length: G = 9 samples.

The modulation scheme of all sub-carriers is 16-QAM. The channel is


a time-invariant channel with the discrete multi-path channel profile
ρ[k] given as follows:

Table 8.2: Discrete multi-path channel profile.

Path index Propagation delay Path power


k τk (ns) ρ[k] (lin.)
1 0 1.0
2 50 0.6095
3 100 0.4945
4 150 0.3940
5 200 0.2371
6 250 0.1900
7 300 0.1159
8 350 0.0699
9 400 0.0462

The propagation delay τk relates to the k-th channel path. Assuming


that the channel is perfectly known at the receiver, plot the symbol
error ratio (SER) of the system over the above multi-path channel and
for the SNR of SNR = 0, 1, ..., 25 dB. Note that the miss-matching
effect must be taken into account.
21

8.2 The parameters of the OFDM system are selected as in the exercise
6.1, except the guard interval length is set to be zero. The channel is
still time-invariant. Plot the SER of the system then compare with
the result obtained from exercise 8.1.
8.3 The channel is in this exercise a time-variant channel with the dis-
crete multi-path channel profile similar to that in exercise 8.1. The
maximum Doppler frequency fd,max on each path is 50 Hz.
The channel is modeled by the Monte Carlo method

1 X L M
h(τk , t) = √ ρ[k] ej(2πfk,l t+θk,l )
X

M k=1 l=1
·δ(τ − τk ), (8.1)

where fk,l = fd,max sin(2πuk,l ), θk,l = 2πuk,l , and M are called the
discrete Doppler frequencies, the Doppler phases, and the number of
harmonic functions, respectively. L denotes the channel length. In
the above given multi-path channel profile, L = 8. The qualities uk,l
are independent random variables, each with a uniform distribution
in the range (0, 1] for all k = 1, 2, . . . , L, and l = 1, 2, . . . , M. The
number of harmonic functions M is chosen to be 40. Plot the SER of
the system then compare with the result obtained from exercise 8.1.

You might also like