+ All Categories
Home > Documents > Ky thuat thong tin so Tap

Ky thuat thong tin so Tap

Date post: 09-Dec-2023
Category:
Upload: independent
View: 0 times
Download: 0 times
Share this document with a friend
101
Transcript

Bô sách

Kỹ thuật thông tin số

T ậ p l

Digital Communication

Technique

Band 1

Digital Communication Technique

Band 1

Matlab Exercises for Wireless Communications

6 - 3 5 5 - 0 4K H K T - 0 5

SCIENCE AND TECHNICS PUBLISHING HOUSE

HANOI

ChenỊỊ-XianịỊ W an g and Nguyen Văn Đức

B ộ SÁCH KỸ THUẬT THÔNG TIN SÓ

TẬP 1 •

CÁC BÀI TẠP MATLAB VÈ THÔNG TÌN v ồ TUYÉN

NHÀ XUÁT BẢN KHOA HỌC VÀ KỸ THUẬT

HÀ NỘI

Bộ sách Kỹ thuật thông tin số

Chịu trách nhiệm bản thảo: Nguyễn Vãn Đức

Tập 1: Các bài tập Matlab về Thông tin vô tuyến

Tác giả: Cheng-Xiang Wang and Nguyễn Văn Đức

LỜI GIỚI THIỆU «

1'rọng việc thiết kế các hệ thống thông tin di động, việc phân tích hệ thông thông qua mô phóng giúp các nhà thiêt kê tôi ưu và thư nghiệm các hệ thông với chi phi nhó nhất trước khi đưa hệ thống thứ nghiệm ra thể giới thực.

Một trong các công cụ rất hữu hiệu cho việc phân tích và mô phong hệ thông được sừ dụng rất rộng rãi trên thế giới đó là phần mềm Matlab. Lý do tại sao Matlab lại tìm được sự ứng dụng rộng rãi như \ậ y là vì Matlab là một công cụ rất mạnh đê thực hiện các phép biển đôi toán học. Bênh cạnh đó nhiều chương trình xư lý tín hiệu số cũng được tích hợp trong các phiên bán mới cúa Matlab. Matlab còn dùng đê điêu khiên các vi mạch điện tư và các thiết bị đo. Có thể nói ngày nay, Mallab là một công cụ không thế thiếu được cho các sinh viên, kỹ sư sứ dụng đề mô phóng và phân tích hệ thống phục vụ cho mục đích nghiên cứu khoa học và tron^ công nghiệp.

Với mục đích giúp sinh viên, kỹ sư và các nhà khoa học tự học Matlab cũng như là việc tự nghiên cứu về các vấn đề cơ bán trong thông tin vô tuyến, tiến sĩ Cheng-Xiang Wang (tốt nghiệp Tnrờng ĐH Tổng hợp Aalborg, Đan Mạch) và tiến sĩ Nguyễn Văn Đức (tốt nghiệp Trường ĐH Tông hợp Hannover, CHLB Đức) giới thiệu một cách có hộ thông 8 bài lập cơ bán về các vấn đề trong thông tin vô tuyến. Một phân các bài tập này đã được sứ dụng cho sinh viên ớ các khóa cao học của Trường Đại học Agder, Nauy. Trong tập tài liệu này, các bài tập vê m ô p h ó n g kênh vô tuyến sử d ụ n g p h m m g pháp R icc và p h ư ơ n g pháp Monlc Carlo cũng được đề cập. Các hệ thống thông tin sử dụng phương pháp điều chế OFDM được trình bày một cách ngắn gọn. Lời giai cùng kết quà các bài tập này được thực hiện bằng chưong trình Matlab.

Sau khi giải hết các bài tập trong tập tài liệu này, người học được trang bị những kiến thức cơ sở trong thông tin vô tuyến, và các kỹ năng lập trình ở môi trường Matlab phục vụ cho mục đích mô phỏng hệ thống.

Tiến sĩ Phạm Minh Việt

Chù nhiệm Khoa Điện tử Viễn thông

Trường Đại học Bách khoa Hà Nội

TOM TẢT NỘI DUNG CÁC BÀI TẠI’

Nội duntĩ các bài tập trong tập tài liệu dược trình bày một cách vắn tát như sau:

Bài tập I: Tính toán và mô phong hàm phân bố xác suất Gauss.

Hàm phân bổ xác suất Gauss là một hàm phân bố rất cơ ban trong lý thuyết thông tin. Nó biểu thị sự phân bổ xác suất cua mức can nhiều trắng. Ọ ua bài tập này người lập trình biết tạo ra m ộ t nm iồn nh iễu

trẩnsì và tính toán sự phân bố xác suất của nó.

Bài tập 2: Tính toán và biêu diễn hàm tự tương quan cua kênh (Autocorrelation function) theo mô hình hàm Besscl. Tính loún và biêu diễn hàm mật độ phố cúa tín hiệu thu khi bị anh hương bơi hiệu ứníz Doppler. Tính toán và biêu diễn hàm phân bố Rice. Hàm phân bố Rice mô ta hàm phân bố xác suất của kênh vô tuyến khi có sự có mặt cua hướng truyền thẳng LOS (Line O f Siưht).

Bài tập 3 : Tính toán và biếu diễn tý suất nhảy (Level-Crossing Rate) cua biến ngẫu nhiên tuân theo phân bố Rice. Tính toán và biếu diễn khoảng suy hao trung bình {average fading duration) của biên ngầu nhiên tuân theo phân bố Rice. Tính toán và biểu diễn hàm phân bố Nakagami.

Bài tâp 4: Mô phòng kênh vô tuycn tviân theo phân hố Rayleigli sử dụng phirơníỊ pháp cúa Rice. Phương pháp inô phóng cua Ricc là phương pliáp mô phỏng kênh vô tuyến dựa vào các hàm tuần hoàn cos() hoặc sin(). Phần thực và phần ào cùa kênh mô phòng là tống cua các hàm cosO hoặc sin() với các tham số của hàm được xác địnli Irước.

Bài tập 5: Điều chế và giãi điều chế sứ dụniĩ ỌPSK. Mô phong hệ thống thông tin sử dụng ỌPSK với kênh truyền là kênh nhiều trắnii (AWGN channel).

Bài tập 6: Đánh giá tý lệ lồi bít cùa hệ thống như ơ bài lập 5. So sánh kết quá mô phòng với lý thuyết. Mô phong lại hệ thốnií thông tin sứ

7

dụng phương pháp điều chế QPSK, nhưng kênh truyền là kênh phàn tập da đường tuân theo phân bố Rayleigh và có sự can nhiễu trắng, i^ánh giá ty lệ lỗi bít cua hệ thống, sau đó so sánh kết quả mô phóng \(Vi ket qua lý thuyết.

Bài tập 7: Mô pho im hệ th ố n g thông tin sư dụng mã kênh là mã cuộn (convolutional coding) kếl hợp với phương pháp điều chế QPSK. Phía thu su dụng phương pháp giai mã cùa Viterbi (Viterbi decoding). t)ánh giá tý lệ lỗi bít của hệ thống và so sánh với trường hợp không dùníỉ inã kênh.

Bài tập 8: Mô phong hệ thống sứ dụng phương pháp điều chếOFDM, trona đó các tham số hộ thống được trọn từ hệ thống liên lạc máy lính không dây HiperLAN/2, kênh truyền được trọn phù họp với kênh ờ mòi trường trong các toà nhà (Indoor channel). Kênh phụ thuộc thời gian (time variant channels) được mô phong theo phương pháp Monte Carlo. Đánh giá tý lệ lỗi mẫu tín hiệu SER (Symbol Error Rate) khi hệ thống sử dụng phương pháp điều chế 16-ỌAM ở mỗi sóng mang phụ và ở các điều kiện kênh truyền khác nhau. Đánh giá chất lượng cua hệ th ố n g th eo tiêu chư ần tỳ lệ lỗi m ẫu tín h iệu S E R khi

độ dài cúa chuồi báo vệ lớn hơn hoặc nhỏ hơn độ dài kVn nhất của trề triiycn dần.

Contents

1. In tro d u c tio n 1 1

2. Descriptions of Exercises 11

3. References 11

Excrcise 1 13

Exercise 2 14

Exercise 3 16

Exercise 4 18

Exercise 5 24

Excrcise 6 26

Exercise 7 29

E x e rc is e s 31

Solution 1 33

Solution 2 37

Sulution 3 45

Solution 4 54

Solution 5 66

Solution 6 70

Solution 7 79

Solution 8 83

10

Abbreviations

ACF autocorrelation functionADF average duration of fadesAWGN additive white Gaussian noiseBEP bit error probabilityFFT fast Fourier transformGSM global system for mobile communicationHiperLAN/2 high performance local area network type 2IFW inverse fast Fourier transformLCR level crossing rateLOS line of sightOFDM orthogonal frequency division multiplexingPDF probability density functionPSD power spectral densityQAM quadrature amplitude modulationQPSK quadrature phase shift keyingSER symbol error ratioSNR signal-lo-noise ratio

1. lu t ro c iu t io n

Matial) is very powerful software tool wliich ha.s been applied in many areas stidi i\s inol)iỉe roiiuTiuiiications. All over the world, Matlah luis been used not Í)IÌỈ>' in aradcinif ('ducations hilt also in iiKỈustrial applications.

riiis script helps students understand fuiulamental principles of mo})ile com- nuiiiications and (lewlof) their M atlah programming skills.

2. D e s c r i p t i o n s of’ E x e r c i s e s

• Exercise 1: Theoretical Ị)lot and s im ulation of a Gaussian probability (lonsity function (PDF).

• Exeicise 2: Theoretical plots of ĩhe autocorrelation function (ACF),sportral (leusity(PSD), Rice distribution, and non-central chi-

S((uare (list lihiltion.

• Exercise Theoretical })lots of the level crossing rate (LCR) cUicl average (luratioii of fades (ADF") of Rico processes, and Nakagami distribution.

• Exei'i ise 4: C’hannel inoclelling by using Rice’s suni-of-siimsoids method.

• Exercise 5: Modulation of QPSK signals and the consteỉlation diagrain [>lot of the r('CiMV(‘(l QPSK signals.

• Exerc‘is(‘ ÍỈ: Bit eii'ov probability of a QPSK system over an AWGN c'haniH'l anti a Rayleigh fiidirig channeỊ.

l\X(ni:iso 7: Bit error pi’ohahilirv of a QPSK systtnu with convolutional

11

• Kxerciso 7: Bit error pi’ohahiiirv of a QPS COÍỈÌIIK íìud ow r a Rayieigli fndiiifi channel.

Exercise 8; Syinhol ( 'nor ratio of an OFDM systeni over a time-variant channel.

3. R c 'fe re n c e s

1) Kiuinit Sii^inon. AĨATLÁB Pmner\ 2nd edition, Department of Mathe- iiiatics. I'liivorsitv f)f Florida. 1992.

12

2) MATHWORKS Inc, M A T L A B High-Pcrfoi~ìĩìance Nuinerii- Coiĩi]iìLt<i tion and Visualization Software, User’s Gniclo, South Natic'k, MA, IĨSA. 1994.

3 ) WWW. ni at 11 wor k . C'O n i .

4) Gordon L. Stiiher, Principles of Mobile Coĩĩìĩìiuĩiicatioĩ}. 2nd etỉition. London: Khiwer Acadfunic Publishers. 2001.

5) J. G. Proakis. Digital Communications, 3ni edition, New York: McCiraw- HilỊ 1995.

6) M atthias Patzold, Mohĩựuĩikkanaele, Germany: Vieweg Sohli Wrlan; GmbH, 1999.

1 T h e p robab ili ty (k^nsity function (P D F ) of a G aussian d is tr ib u te d random variab le // is given by

„ ( . , ) = ( 1.1,2ơ ị

where ììiị and (7 den o te tlie mean value and th e variance of /X, iesj)fX’tively. For ììì , — 0 an d ơị, — 1, sketch th e P D F p^{x ) in the interval —4 < J’ < 4. Check w hether or not th e P D F result is correct 1)V using í ị^^Pị^{x)dx = 1.

H in t : list ' th(' M A TL A B funcrioii trapz to c o m p u t e th e integral a n d US(' for t h e d i s c r e t iz a t io n o f X t h e M A TLA B c o m m a n d X — - 4 : 0.05 : 4.

13

E x erc ise 1

1.2 A d ig ita l transm iss ion system always includes som e w hite noise which is usually G au ss ian d is tr ibu ted . Use th e M A TLA B function mndĩỉ to g enera te a real-valued wliite noise vector having a lengtii of’ lOOOOOO. D(‘te rn iine the m ean value, the variance (power), and the P D F of the noise from th is noise vector. P lo t th e P D F and com pare it w ith th e theore tica l curve in (1.1) under th e condition th a t th ey have th e sam e m ean value and variance".

l i i i t t : Use thi) M A TL A B functions mean, var, an d h i s t

2.1 For tho 2 D isotropic sca tte r in g Hat fading channel inoilel (C1aik('s m odel), th e au toco rre la tio n function (A C F) OÍ th e real and iiuagi- n a ry com p o n en ts of th e rew ived com plex signal ợ(/) = / / / (0 + )c a n bo ex [)resso d In'

14

E x erc ise 2

where íỉp r e p n ‘sents th e to ta l reci*iv('(l ])()\ver, j\n is th(‘ luaxiuiiiiii D oppler frequencv, and ./o(') deiiotcis th e zoroth-orcli’r lỉessel func­tion of th e first kind.

1) In GSM system s, th e carrier íVexỊuency is given In’ /(. 900MHz. For a m obile s ta t io n with th e spiH'd of V ~ lt)9.2 k n i/h . ca lcu la te th e inaxinuim Doppler íVecỊuency actord iiig to

/,„ = ^ = -‘--i' . (2^2,A p C'4)

where Ac is th e w avelength aiKỈ r:o = 3 X 10” in /s (le^iiotos tli(' speed of light.

2) C o m p u te th e A C F ỢgiQỊÌT) over th e interval 0 < r < 0.08 s and sketch your results. Use tlio value 2 for iìị,.

3) W h a t is th e value for < y/5/ ( 0 )? W h a t is tÌK' n*lati()ĩislú]) 1)(*- tw o en ộịỊỊgiiO) a n d iij,.

H i n t : Use th e M A TLA B fuuctiou besstdj fur {he cak iila tio ii of tlu' Bessel function Jo( )-

2.2 For C la rk e ’s m odel, th e power spec tra l density ( I ’SD) of f//(/) and g q i t ) can he expressed by

S , , M ) - =J h ___ 1. f < f

0 , /

C alcu la te 5 g ,p ,( / ) am i sketcli it. Use th e saino values for and /„ , a« in Exorcise 2.1.

15

.’,.'5 It' the 2 D isotropic .scattering enviroiiineut consists of a scattered coiiii^oiieiit Ị)lus a s tro n g line-of-sight (LOS) coinj)onent, th e jKob- al)ility (loiisity fuiu'tioii (P D F ) of the reccivcci signal aiiiplitiule a ( / ) = f/{t) is given by th e following Rice d is tr ib u tio n

2,r(A- + l ) ......M-r) - p

.?• > 0,

K(K + 1),I.2

i l h 2xK {K + 1

(2.4)

Here, /()(•) denotes th e zero th-order niodifiod Bessel function of the iirst kind, = E[fv^(í)Ị = + '2bo, and K deno tes th e Rice factor,which is tlefiiu'd as th e ra t io of the LOS power to th e sca tte red |)0\ver 26(). i.e., K ~ s^/2bo.

1) For iip = 1, c o m p u te Po(.r) and sketch it for th e following Cilses; I\ = 0, K — 3, a n d K = 80.

2) W hen K = 0, th e Rice P D F will teiKỈ to which d is tr ibu tion?«

3) W h t ‘11 K — oo, th e Rice P D F tends to w h id i d is tr ib u tio n ? In this ca.s(\ (loi's tho channel ytill exist any fading?

H i n t ; Use tli{‘ M A T L A B function besseli for tlie ca lcu la tion of th e inocliiiccl Bessel function /o(')-

2.4 For Rice fading, tlie P D F of the squared envelope, i.e., a ‘ {t) = is givt'u by th e following noii-cciitral chi-sqiiare d is tr ibu tion

+ 1

:r > 0 .

c*xp(/v + l);r

f2„/u \

K { K + l ) xa . “ /

(2.5)

1) For ii,, = 1, con ipu to Pa'^{x) and sketch it for th e following ca.ses: K = 0, K = 3, and K — 80.

2) W h en K = 0, ]>a'^{x) will tend to wliich d is tr ib u tio n ?

3) W hen K —* oo, j>n2 {x) tends to which d is tr ibu tion?

3.1 T h e envelope level-crossing r a te (LCR ) of Rico J)n>c(\sses can ('XỊ)resso(i a.s

16

E x erc ise 3

)(’

L/,(7?) = y/27T( A' -f t 1 ) ) , ( : i 1)

where p — / ? / y ^ w ith iij, = -f 26(), and th e Rice factor I\ -

s ^/21)q. For = 1, co m p u te tlie normalized LC'R L i i { R ) / j \„ and p lot th is function for th e following cases: K -- 0. K — 3. and K = 10. Give your results for th e lovel R € {0,0.05,0.1,- • s l .S } .

H i n t : Consider R as ii vector defined 1)V r = 0 : 0.05 ; 4.5, and ĩiiakí' u s e o f t h e o p e r a t i o n s " a i r a y p o w e r ' ' a n d " m r a y ĩ n a l t r p l u a t ì o n " .

3.2 T h e average d u ra t io n of fcides (A D F) of Rice procossos is given 1)\-

i ( „ ) = ' ’( » ^ c , , ,' ' L„{R) Ln{B) ■ ' ■

w here Pa{^') L f i { R ) a re given as in (2.4) a n d (3.1), i'i‘S])e(:ti\'('ly. For = 1, co m p u te th e norm alized A D F 7(7?) * fjn and Ị)lí)r it for th e following cases: K — 0, K = 3, aiKỈ K ~ 10.

3.3 T h e N akagam i d is tr ib u tio n is given by

where Q,, — E [ a ‘ {t)]^ an d r ( ‘) denotes the G an in ia fuiK tion.

1) For íỉp — 1, c o i n p u t o a n d ski^tch it for tlì(' following casrs:r o r = i , c o i n p u i o a i K i sK('ĩc:n ÌÌÌ = 1 /2 , ÌÌI = 1. /;ỉ = 4, and w ~ 20

2) It is WC'II known th a t the Rice (listribtition ỈIS shown in (2.4) can closely be aj) |)roxim ated by using th e following n 'la t io n between th e Rice factor K and th e Nakaganii sh ap e factor ÌÌI

P lo t these two d istr i lm tions in the sam e figure for K — 2. i.(\. in — 1.8, and com pare the results.

H i n t : Use th(' M A TLA B func tion Ijaninia for the (.ak n la tion of th e C a n im a function r( ).

17

J A i H Ọ C Q u c :-IA h a fv u i ÍRUNG TẦM THÔNv,- ' I THƯVItN

i l - M / M Ể Ả Í

18

E x erc ise 4

A fading channel s im ula to r can be constnK ’ti^d einj)loyiug R ico’s sum of sinusokls. By using th e Rice m e thod , the coinj)lex low-pass fading signal is in general given by

ỹ ( 0 = in{f) +JĨi2ự) ■ '4

where

ĩhự) = «w(27r/,,„/ + , i = 1,2 •1.2

T he so-called D oppler coefficients c, d iscre te Do[)})lor fro(inoncios and Doppler phases 0, n t ho de term ined ỉ)y using the m o th o d o f i 'x ac i DoỊ)pler sp read (M ED S) and are given ill th e following closod torin

i,ĩl

k n

0, . „

2 b

Ni Vj

2

(4.;ia)

(4.;ih)

(4.3c)

for all n === unci / = 1,2, respectively. In (4.3), b is th('variance of gi{f), an d dcuotos th e inaxiiiiurii Doppler frcHjuency. Noto th a t th is s im ula to r is of de ten n in is t ic t y \ ) C since all the p a ra m e te rs aro known and kc'pt cons tan t during sim ulation. Fig. 4.1 shows th e s t ru c tu re of the corrospoiKling de ten n in is t ic siiiiulation m odel for Rayleigh fading f h a n i ie l s , w h e r e n ( / ) indic a t e s t h e r ece iv ed s ig n a l e n v e lo p e in tli(' (■t)niỊ)lox hascbaml.

19

cos( 2 ; r / | ,/ + ơ, ^)o-

cos( 2.7/, f , ) o

cos( 2/ự\ t + ) o-

cos(2 .t/, i + (Ầ ^^) o-

C’ I . i->ỗ>-

■ ®-

->®-

c.

+ g , ( 0

g(0

^2(0

a(l)

Fig. l . l : A (l(?t('niiiuistic Raylcigli fading channel sim ulator.

4.1 I'or t h e g iv en numlKn- OÍ s in u s o id s N \ — 9 a n d A 2 = iO) co ĩn Ị) i i te t h e s in n i lo t io i i in o íỉo l Ị)ara íneters Cj,i, a n d ỚÍ a c r o r d in g to (4.3a) (4..'ic) 1)V using b — 1 and /,„ = 91 Hz. W rite your resu lts in Tal)lc 4.1 given oil t lie next pag( \

4.2 DcvcIoị) a M A TLA B function ni-file to sin iu la te th e de term in is tic Ị)rocesses g , { t ) for i — 1,2. Use t lic ( juanti t i es f i n , ^iri, 'à ĩìả t

as iiiỊ)iit a r g u m e n ts .

4.3 Writo a M ATLAR srrÌỊ)í ni-filo to Cixvry o\it tlio sìĩnulatif>!i of tlìí'(.■liaiinel a iuỊ)l ittu le ( \ { t ) = |.íỳ(OI = Lời(0 plt>t òíi/:ỉ(/) “2í)logã(/). Solve th is problem by m aking use of your function in-file (U'vclopod in Exercis(‘ 4.2. T he simulation model j)arainetors Cm, hu^ ‘ 1 ítií' given as listed in Tahle 4.1. Use th e sinnila-tion tin ie 'fsan ~ 0.4 s and th(' sam pling íVetỊueiicy /a = 270.8 k llz , which corn^spoiKÌs to th e syuiho! ra te used in GSM . If a vehicle drives w ith a vSj)eo(l of I' = 109.'■ k n i /h , w hat is the clistaiic(‘ it cov- (‘rs in íh{' siiuulation tiino'.'’

H in t : T he cliscretiziition of the tiiiu' t can be expressed as t =0 : l / f s ■Ts rn.

l . ỉ S im ulate tho íletcrniiiiistic functions g\{f ) , and õ ( / ) 1)V us­ing the saìiiỊ)ling frequoiK'V f s = 50 kHz and the s im ula tion tiiiH' T^jtn “ 20 s. D eten n in o th e mean vahio and variance of //{/), and 0 (f) . D otern iine th e probability d('iisity function ( I ’D F ) OÍ /ỹ i(/) and ã{t ) by using h is to g r a m s . Whicli (lÌ8triỉ)uíioiis ái) i h v y a p p ro x ­im ate? C o m p are th e P D F of gi{t ) w ith th e theore tica l rrsiilt given in (1.1), w here = 0 and = 1. C om pare the P D F oi’n ( / ) w ith th e theo re tica l result Pai^:) given in (2.4), w here iijj — 2, aiul K — 0.

*

H i n t : Use th e M A TLA B functions mean, ỉitd, and lihif.

4.5 D eterm ine a p a r t of th e signal gi{t)\t^Ị from th e s im ula tion resu lts OỈ in th e interval / ^ [ 1 0 0 0 0 / /s , 2 0 0 0 0 / /s], where J\, 1000 H /.

F ind th e au toco rre la tio n function (A CF) ỢgịỊỊiir) QÍ f ỉ \ ( t ) \ te ỉ plot it. W h a t is th e value for ớgỵgị{OỴ-

H i n t : Use the M A TLA B function :rc0 7 T W'ith tlio ()Ị)ti()ii hìdsed

20

21

ị 7 Ì /.,n (Hz) c.,„ ơ,,„ (rad)

1 1 i

1 0

1 31

111iii

1

11

1 !)

2 1

2 0tmt

9 3

*)

2

2

0 10

Table i.l: Pariunoters of the simulation model {fm = 91 Hz. h = 1, Ny = 9,

As = 10),

■Ị-(i 'I'he ACF' ó y j y j ( r ) t)í íỹi(^) c a n \ìv í'XỊ)ress(Hl hy

4 i9.(’') = % coK(27r/i,„ r ) . (-l..})íl=l ^

C o m p u te 0 ,;iyj(T) ov(M' th e inti'i'val u < r < í).08 s aiKÌ sk(Hcli yom' result in tho saino figure as iu Ex(.'R‘ise 4.5. For t lu ’ sake íìf coinparison, the ideal A C F ộgịỊỊịÌT) in (2.1) is r('(juirccl to 1)(' shown in th is figure as well. Use the value 2 for Qp and 91 Hz for fj„.

4.7 D eterm ine and sketch tho Ị)o\vor spectra l density (PSD ) ofthe signal ỹi(Olíe/-

H in t : llso th e M A TLA B functions iff and f ftshift. Xí)niiali/( ' ĩ l ir inea.siirc'(l P SD to its nuniher of spectral coni])onents.

4.8 T h e PSD Sa. gi i f ) of the sinm latiou model is given by

(4.r))

Draw 5'yjyj(/) in th e sam e figure as in Exercise 4.7. C()inỊ)íU(' youl I'csuhs w ith th e ideal PSD S'giyjl/) given by (2.3), wluue íìị, = 2 and f,n = 91 Hz.

4.9 S im ulate tho cliaiiiiel amỊ)litu(le ã ( / ) by using f ~ 0 : I / • T^un’ where i s — 10 kHz and = 10 s. Evalỉiatí ' the e n v o l o Ị X ' level- crossing lalt- (LC R ) Lị ì ỊĨÌ) ,

4.10 T h e L C R L r {ỉ ì ) of th<‘ siiiiulation niodol is given by

Ả -ỉi:^ / ỉư í j = ỵ:

where

ậ = 2 n ^ Y ^ i c u J u n f . (4.n=l

Draw Lỉi{ l ì ) by using b = I in the sam e figure as ill Exorcise 4.9. C’oniparo your rosults w ith tho ideal Lịi{f í) as givon by (3.1). wliore ỈL - 2, A - t), a n d /,n - 91 ỈỈ/.

23

5.1 T h e Q P S K signal constollation hy using Giriv oiK'iKling is sliíAvỉi in Vig. 5.1. T h e (X)nst(‘llati(jn ỊKŨMts arc located syiuiiiinricallv at a un it circk’ in the complex (loniain. Tlu'ii. the Q P S K roiuỊ)l('X signal w c to r s c a u he exj)r(*ss('(l by

;» = (). 1 ,2 .3 . (5.1)

wlicre 0„1 € { f , Y - ^ } - M A T L A B , \V{- m o d e l a h i i ia rv hit sequence ivs a finite longth vector. G enera te a l)it vector of length 50000 a n d thoĩi i n a Ị ) tho l)its on to th e com p lex (la ta sy ii ihols 1)V us­ing Q P S K nicHÌulatioii w i th G ra y oiK'oiliiig. P lo t tli(* coiisti^lhition iliagrain.

H i n t : lTs(' tlu* M A TLA B functii)!) raiidnii for geniorating a h inarv hit se(Ịuenco OÍ ■'0‘’s and " r ' s with íXỊual Ị)iohal)ility.

. , 0 0

24

E xorcise 5

• 10

Fi^. 5.1: C\)1UJ)1(‘X Sigual-SỊ>ỈK‘(' (liagrani for C^PSK w ith Cỉray (Micod- ing.

5.2 Su[>posc t h a t t h e al)OV(' ino(li ilat(‘(l Q P S K s ignals a r e t r a u s in i t t e i l th ro u g h an additive w hite G aussiau noise (AW GN) channel. T h vn . the received signal is th e add ition of the Q P S K signal an d th e white G aussiati noiso. Finst, generate a coniplex-valuod w hito G aussian uoiso vector, whoso length is identical w ith th a t of th e Q P S K signal voctor. Use th e value () (IB for th e sigiial-to-noise ra t io (SN R) in

(Iccihel. T ho SN R is (letinocl ÍXS the ra t io of tlio hit energy to noise Ịxnver, i.e.. SNR — Eh/No- r^lot th e conste lla tion d iag ram of th e rt'coived signals. Yon a re expected to see th e so-called G aussian clouds a ro u n d th e original Q P S K signal points. C hange thC 'S N R (e.g., 3 clB) an d plot again th e conste lla tion d iag ram of th e received signals.

H i n t : th e M A TLA B function randĩi for g enera ting G aussiannoise.

25

G.l Let XIS consider a Q P S K ])asol>aiicl transm iss ion sy s tem fus í>h(_)\vĩi ill Fig. 6.1. T h e t ra n sm it te d b its of leng th lOOOOO are inaỊ)Ị)(HÌ (Hitu th e Q P S K com plex d a ta synil)ols by Iisiii^ G ray encoding as shown in Fig. 5.1. T h e m o d u la ted Q P S K signals are I ran s in i tto d throuj^h an additi\ 'e w hite G aussian noise (AW GN) channel. We will US(' th e m ax im u m likelihood (ML) receiver to d e tec t th e recfMVi'd sig­nals. In o th e r words, we com pare the (livStance of a receivf'd s>’uil)ol to all possible sym bol values and choose th e one th a t niiiiiiiiizt's th e d istance . A fter Q P S K dem odula tion , th e received hits will t>(‘ com pared w ith th e tra n sn ii t ted bits. C o u n t th e errors occiii nvl du r ing transm iss ion and plot the bit e rro r pro l)ability (I3EP) for th e signal-to*noise ra tio (SNR) of 0, 2, 4, and 6 (IB. N ote th a t ihw to the long simulation time, it is important to vSave the obtaiiH'il s im ulation r e s u l t s by u s in g the M A TLA B function save. The ( la ta c a n b e r e tr ie v e d 1)V u s in g t h e fu n c t io n load.

26

E xerc ise 6

A W G N

B itS o u rc c ' <M odulation V

' ) . Q P S Í C . B .t s .n kDem odulation

B E R

C alculation

Fig. Ơ.1: A Q P S K traiiHniissioii system over an AW GN channel.

6.2 For Q P S K w ith G ray encoding over ail A W G N chaniiol, th e ihoo- rctical B E P Pi, can 1)0 ob ta ined from

where Q(-) deno tes th e Q function and % = Eh/No is th e SXR. N ote t h a t there is no Q function availal)le in M A TL A B . Fortunate ly ,

it can 1)0 (l('t(niiiinod I)V using th e roiuj)leine!ntary error fuuctioii ('rfc(-) a,s follows

Q (i ') = ^ e r i c ( ^ ) . (6.2)

Conij)utc Ph and plot it for th e SNR of 0, 2, 4, and 6 (IB. C o m p are this ihoorotical result with th e s im ulated B E P in Exercise 6.1.

H i n t : th (‘ M A TLA B function erfc.

G.3 p'ig. 6.2 shows a transmis8Ìon chain com posed of a Q P S K m o d u la ­tor. followed by a slow Rayleigh fading channel and a Q P S K de­m odu la to r. T h e complex fading channel coefficients are g enera ted by u s in g ( 4 . 1 ) , w h e r e C i n a n d f , n g iv e n b y (4 .3 a ) a n d ( 4 .3 b ) , respectivoly. T lie Doppler Ị)hases ti.ri 'àTV eq u a ted w ith th e real­izations o f a r a n d o m genera to r uniformly ( i i s tr ib u te d over (0,27T . O th e r quantiti(\s are chosen a*s follows: /„1 ~ 91 Hz, I) = 1 /2 ,

= 9, anti N ‘2 — 10. Since th e ML receiver is still used here, the receiver has th e knowledge of th e com plex fading coefficients. S im ulate th e w hole transm ission system by using 500000 t ra n sm is ­sion l)its an d tlie sam pling frequency fs — 270.8kH z. P lo t the B E P for SNR = 0 ,5 .1 0 ,1 5 ,2 0 clB. R em em ber to save th e o b ta in ed siinnlatioii results.

AW GN

B,t Source . Q f X; ) T o P S K ' , . B i, SmkModulation 1 Fading Channel vX ^ Demodulation

BER ị Calculation

Fig. 0.2; A C^PSK transniission chain over a Rayleigh fading c h a n n e l

27

G.'l F'or Q P S K over a slow Rayleigh fading channel, tlie theore tica l B E P is oxpr('ssed l)y

1Ph - -

1 + 7b(6,3)

28

/ 2 .wliere 7 ,, = 2l)Eh/N() deno tes the average received SNR. For I) c o m p u te Ph an d Ị)lot it for SNR = 0 ,5 , lO. 15,20 dB. Coinj)an> till theore tica l result witli th e s im ula ted B E P ill Exorcise 6.3.

29

E x erc ise 7

[■'ig. 7.1 shows a coded Q P S K baseband tranHiuission system . T h e s t ru c ­ture of thv convolutional coder w ith th e ra te /?(. = 1 /2 an d th e c o n s t r a in t h'ligth K “ 3 is shown in Fig. 7.2. W hat is th e im pulse response of th is (ouvolutional coder? We assum e th a t the encoder s ta r t s a t th e all-zeros s ta te and the {iocoder uses th e Viterbi a lgorithm w ith h a rd decision. S im ­u la te th is c o d i n g s y s t e m h y u s in g 2 X 10^ t r a n s m is s io n b i t s a n d p lo t t h e BEP for SNR 0 ,2 ,4 (IB. C alcu la te the coding gain for B E P — with I(*spect to th e uncoded B PSK system. N ote t h a t th e B E P o f un- ( ()il(‘(l BPSK is essentially th e sam e as th a t of uncoded Q P S K .

Bit Source ConvolutionalCoder

Q PSKModulation

BERCalculation V.

Bit Sink ■Viterbi

Decoder■ — QPSK

Demodulation

Fig. 7.1; A coded Q P S K transm iss ion system over an A W G N channel,

30

input

first output

output

' ( ■ V 'second output

Fig. 7.2: B inary convolutional encodor (/?,. = 1 /2 , A' = 3).

H i n t : Use th e iMATLAB ftuic’tions convenc, poly2t.relUs for tli(' c o iivo lu tional coding and vitdec for th e Viterl)i (iecoding.

31

E x erc ise 8

8 . 1 IiiiỊ)lernent an O r th o g o n a l Frequency Division M ultip lexing (O F D M ) system using th e following p aram eters taken from H ip e rL A N /2 s tan d a rd :

- B a n d w id th of th e system : D = 20 MHz,

“ Sampling interval: Ta 1/Ổ — 50 ns,- F F T -leu g th ; .V = 64,

- O F D M sym bol d u ra t io n : Ts = N ■ Ta = 3.2 fis.

- G \ian l interval lengtli: G — 9 s a m p le s .

T h e n io d u la t io i i s c h e m e o f all su h -c a rr ie rs is IG -Q A M . T h e c h a n n e l is a timii-iiivariaiit channel w ith the d iscrete m u lt i -p a th channel j)rofile p[k] g iv e n a s fo llow s:

Table 8.2: Discrete multi-path channel profile.

Path index Propagation delay Path powerk n (iis) p k (liii.)I 0 1.02 50 0.60953 100 0.49454 150 0.39405 200 0.23716 250 0.19007 300 0.11598 350 0.0G999 400 0.0462

riie Ị)r()Ị>agatiou cỉe^íiy Tk relates to the Ả:-th d ia n n e l p a th . A ssu m ­ing th a t the channel is perfectly known a t th e receiver, p lo t th e .syiiii)ol error ra t io (SE R ) of the system over th e above m u lt i -p a th cliaiinel an d for SNR = 0 ,1 , . .. ,25 (IB. N ote th a t th e m iss-m atch ing cif('ct m ust be taken in to accoimt.

8.2 T he Ị)arani('ters of th e O F D M system are selected as in th e Exercise 8.1. except ih e g u a rd in terval length is set to be zero. T h e channel

is still tinie-inviiriant. P lot the SER of th t‘ systoni and tli('u (■()iiiỊ)aì(' w ith th e result obtaineci from Exorcise 8.1.

8.3 III th is exercise, th e channel is tiiiie-variant w ith th e d is n e re m ulti­p a th (‘hannel profile sim ilar to th a t in Exercise 8.1. T h e iiiaxiniuMi D oppler froquency /diiiax on each p a th is 50 Hz.

T h e channel is UKKỈelod by th e M onte Carlo m e th o d

32

h{T, t ) = (H. 1)k=\ / = 1

where fk,i = fd.umxSm{2nUk,i), 9k,I = 2nuf , j , am i M are callt’d the discre te D oppler fn'queiicies, th e Doppler phases, an d th e miiiilK*r of harm onic functions, respectively. L denotes th e cliaiinel l(‘ngth . In th e above given m ulti-p a th channel profile, L “ 8. T h e (luantitii 's Uki a re independen t random varial)les, each w ith a un ifon ii (listril)- u tion in th e range (0,1] for all k = 1 , 2 , . . . . L, an d I ~ Ì . 2 , . . . , M. T h e n u m b er of harm onic functions M is choscni to \>e 41). Plot tli(' S E R of th e sy s tem and th en com pare with th e result ol)tain(xl from Exercise 8.1.

33

Solution I

%"/o Calculation of the probabilitv density function (PDF) of % a Gaussian distributed random variable%%========================================

l_a = 0.05; % Sampling intervalx= -4:t_a:4; % Set X variable

% Calculation of the PDF of a Gaussian distributed random variable

p = (1 /sqrt(2*pi))*e.\p(-x.''2/2);

check = trapz(x.p); % Integration o f p

% Remark: T'lie i n t e g r a t i o n of P(x) for -4 < = X < = 4 must be equal to 1

plot(x,p);title('\fontsize{ 12JPDF of a Gaussian distributed random variable');\label('xVi-ontSize',12);ylabel('P(x)',TontSize',12);

Exercise I.l

Matlab program

34

Result

PDF of a Gaussian distributed random variable

Gausian distribution

Exercise 1.2

IVIatlab program

% Comparison o f Gaussian distributed PDF with simulation result

clear; % clear all available variablesm_inu-0; % mean valuesigma_mu= 1; % variance

35

n - lOOOOOO; % length o f the noise vector \"-4 :0 .05:4 ; % set X variableP“ { ]/sqrl(2*p!)*sigma_mu)*exp(-(\-m_nui).'^2/2*sigmajiiLi^2);

% calculate the Gaussian distributed PDF ciieck"'trapz(x.p)

% the integration o f p(x) for -4 <= \ <= 4 must cqua! I .plot(x.p.'r’); hold on:

%........ ...........................................................- - .......................................................................................................................................

% Generate a random vector, and calculate its distribution% ..........................................................

y= randn{ l,n); m = mean(y)

% mean vaiue o f the process yvariance =

% variance o f the process yx2=-4:0.1:4;C=hist(y,x2);

% calculate the history o f the process y Stem(\2,c/n/(x2(2)-x2( Ỉ)));

% the calculation "c/n/(x2(2)-\2( 1))" is to change from the % liistorv diagram to the PDF

title(’(iaussian distributed PDF');\labei('X');ylabe!('P(X)');lcL ;end( ' t hco ic t i cu r , ’e x p e r i m e n t a l ' ) , lio!d off;

36

R esults

Gaussian distributed PDF

Causian distribution (theoretical and simulation results)

37

Solution 2

Exercise 2.1

Matlab program

% Bessel function “> time autocorrelation function o f the mobile channel

clear;f_c=900e6; % the carrier frequency in HzC_0=3e8; % the speed o f light in m/sv=109.2e3/3600; % the mobile station's speed in m/st'_m-v*f_c/c_0; % the maximum Doppler frequencyohm_p=2; % the total received powert=0;0.001:0.08; % the time interval in secondsphi_glgi=(ohm_p/2)*besselj(0,2*pi*fjn*t);

% the autocorrelation functionplot(t,phi_gIgl);

title(The autocorrelation function A CP); xlabcl('\tau’);ylabei('\phi_{glgl }(\tau)'); iegend( '\ph ijg ig l} (\tauy); phi_gỉgl_0=(ohm_p/2)*besse!j(0,0);

38

Results

The autocorrelation function ACF

Bessel function: a model o f the autocorrelation function o f the radiochannels

39

% Doppler spectrum%=======^===^=:==

clear;f_c=900e6; % the carrier frequency in HzC_0=3e8; % the speed o f light in m/sV=l09.2e3/3600; % the mobile station's speed in m/sí'jTì=v*f_c/c_0 % the maximum doppler frequencvohm_p=2; % the total received powerZ - - 100; 1:100; % the time interval in secondsfor 1:201;

i f abs( 0 f_mS_gỉgl(i)=(ohm_p/2*pi*fjTi)/sqrt( l-(í7f_m)'^2);

elses„glgl(i)=0;

endendplot(z,S gigi)titie('1'he power spectra! density (PSD)’) xlabeK’f)v la b e lC S Jg ig l i (O ’)iegcnd{ 'S_íg!gỉ}(0’)

F^xercise 2.2

M atlab program

40

Results

2000

1800

1600

1400

1200

ƯÌ800

600

400

200

0 -100 -80 -60

The power spectral density (PSD)T-----------1---------- 1-----------1--------

•40 -20 0 20Oopp<«r 1re<nuency m Hz

40 60 80 100

Doppler spectrum

41

% The Rice [distribution%=================clear;k0=0;kl=3;k2=80;k=kO; % the ricc factor k =s^2/2b_0\=0:0.01:3; % the time interval in secondsohm_p= 1; % the total received power

p_eifa=(2.*x.*(k+l )/ohm_p).*exp(-k-((k+I ).*x.^2/ohm_p)).*besseli(0,(2.*x.*sqrt(k*(k+l)/ohm_p)));plot(x,p_elfa)hold on

k = k l ;

p_elfa! =(2.*x.*(k+1 )/ohm_p).*exp(-k-((k+1 ).*x.^2/ohm_p)).*besseli(0,(-.*x.*sqrt(k*(k+l)/ohm_p)));plot(x.p_elfal,'r.')hold on

k=k2;p elfa2=f2.*x.*(k+l Vohni p).*expi-k-((k+1 ).*x.''2/ohm_p)).*besseli(0,(2,*x.*sqrt(k*(k+l )/ohm_p)));plot(x,p_elfa2,’g-.’)title(’The Rice Distribution')xlabel('x')ylabel('p_|\alpha}(x)') icgend('k=0’; k = r . ’k=80') hold off

F>xercise 2.3

M atlab program

42

Results

The Rice Distribution

Rice distribution with different values o f the Rice factor

43

% T h e non-central chi/square Distribution

F.xercise 2.3

M atlab program

k0=0;k l=3;k2=80;k=kO; % the rice factor k =s^2/2b_0\^0 :0 .0 ] :3; % the time interval in secondsolim_p^ 1; % the total received power

p_alpha^(k+l)/ohm _p.*exp(-k- ...((k+1 ).*\./ohm p)).*besseli{0,(2*sqrt(k*(k+l).*x./ohm_p)));plot(x,p_alpha)hold on

k-kl;p^alpha 1 1 )/ohm_p.*exp(-k- ..,((k- 1 ).*\./ohm_p)).*besseli(0,(2*sqrt(k*(k+l).*x./ohm_p))); plot(x,p_aiphaK'r.')

k=k2;p_aipha2=(k+1 )/ohm_p.*exp(-k- ...((k+1 ).*x./ohm_p)).*besseli(0,(2*sqrt(k*(k+l ).*x./ohm_p))); plol(\,p_alpha2,'g-.’)title(The non-central chi-square Distribution') xlabeirx*)ylabel(’p j \a lp h a ^ 2 j (x ) ') iegend(’k = 0 ';k - r ;k = 8 0 ') hold off

44

Results

The ncKi-<»ntral €iii-square Distnbulion

Non-central chi-square distribution with diiTerent values o f the Rice factor

45

Solution 3

%================================% T he level crossing rate o f the Rice processes0/ —----- -------------—---------- ------------------------:------/0------------------------------ --- ---------- ------ ---------

F'xercise 3.1

M atlab program

clear;k0=0; % the Rice factork l=3;k2=10;R=0:0.05:4.5; % the vector o f amplitude levels

ohm_p= 1; % the total received powerrau=R./sqrt(ohm_p);k=kO; % the rice factor k =s'^2/2b_0

L_R=sqrt(2*pi*(k+1 )).*rau.*exp(-k- ...(k + 1 ).*raii.'^2).*besseli(0,(2.*rau.*sqrt(k*(k+1))));plot(R,L_R)hold on

k=kl;L_R 1 =sqrt(2*pi*(k+1 )).*raii.*exp{-k- ...(k+1 ),*rau.''2).*besseli(0,(2.*rau.*sqrt(k*(k+l)))); plot(R.L_Rl,'r. ')

k=k2;L_R2=sqrt(2*pi*(k+l)).*rau.*exp(-k- ...(k+l).*rau.''2).*besseli(0,(2.*raii.*sqrt(k*(k+l))));piot(R,L_R2,'k-.')title(The Level Crossing Rate (LCR)') xlabel(-R')ylabel(’L_R(R)/f_m') iegend('k=0','k=l', 'k=10') hold off

46

Results

The Level Crossing Rate (LCR)

The level crossing rate o f the Rice processes

47

Kxcrcise 3.2

M atlab program

% The average duration o f fading o f the Rice processes

clear;k()=0;kl=3;k2=10;R=O.OOOI :0.05:4.51; % the vector o f amplitude levels ohm_p=1; % the total received powerrau=R./sqrt(ohm_pi;k=kO; % the rice factor k =s*2/2b_0L_R=sqrt(2*pi*(k+l)).*rau.*exp(-k- ... (k+l).*rau/2).*besseli(0,(2.*rau.*sqrt(k*(k+l)))); for r = 0:0.05:4.5

x=linspace(0,r); a=0:0.05:r; i=length(a);p=(2.*x.*(k+1 )/ohm_p).*exp(-k- .,.

( (k+ 1 ).*x.^2/ohm_p)).*besseli(0,(2.*x.*sqrt(k*{k+l)/ohm_p)));CDf-'(i)=trapz(x.p);

endA D i= C D F ./L _R ; p!ot(R,ADF) hold onk=k 1; % the rice factor k =s^2/2b_0L_R I =sqrt(2*pi*{k+1 )).*raii.*exp(-k- ...(k+1 ).*rau.*2).’*'besseli(0,(2.*rau.*sqrt(k*(k+l)))); for r = 0:0.05:4.5

x=linspace(0,r); a=0:0.05:r; i=length(a);p=(2,*x.*(k+l)/chm_p).*exp(-k- ...

{(k+l ).*x.^2/ohm_p)).*besseli(0,(2.*x.*sqrt(k*(k+l)/ohm_p)));CDFl(i)=tr;ipz(x,p); % the integration of the p function

endAD F1=CD F1./L Rl;

plot(R,ADFl,'r. ') hold on

48

k=k2; % the rice factor k =s^2/2b_0L_R2=sqrt(2’'‘pi*(k+l)).*rau.*exp(-k- ... (k+l).*rau.''2).*besseli(0,(2.*rau.*sqrt(k*(k+l)))); for r = 0:0.05:4.5

x=linspace(0,r); a=0:0.05:r; i=length(a);p=(2.*x."'(k+1 )/ohm_p).*exp(-k- ...

({k.+ l).*x.*2/ohm_p)).*besseli(0,(2.*x.*sqrt(k*(k+l)/ohm_p))); CDF2(i)=trapz(x,p);

end

ADF2=CD F2./L_R2; plot(R,ADF2,'g-.') axis([0 2 0 3])title(The average duration o f fading (ADF)')xlabel('R')ylabeK't(R) ♦ f_m')legend('k=0','k=l', 'k=l0')hold off

Results

49

The average duration of fading (ADF)

50

Exercise 3.3.1

IMatlab program

% The Nakagami distribution

clear;m l =0.5; % The Nakagami shape factorm2=l;m3=4;m4=20;ohm_p= 1;x=0:0.05:3;m =m l;p_alphal=(2*m*m.*x.'X2*m-l)/gamma{m)*ohm_p'^m).*exp(-m.*x.''2/ohm_p);plot(x,p_alphal)hold on

in=m2;p_alpha2=(2*m''m.*x.'X2*iTi-l)/gamiTia(m)*ohm_p^m).*exp(-m.*x.*2/ohm p); |3lot(x,p_alpha2,'r.')

m=m3;p_alpha3=(2*m''m.*x.'^(2*m-l)/gamma(m)*ohm_p"'m).*exp(-m.*x.'^2/ohm p); plot(x.p_alpha3,'g-.')

m=m4;p_alpha4=(2*m''m.*x.'^(2*m-l )/gamma(m)*ohm_p'^in),*exp(-m.*.\."'2/ohm p);plot(x,p_alpha4,'m--')hold offtitle('The Nakagami distribution p_{\alpha}(x)') xlabei('x')ylabel('p_{\alpha}(x)’) legend('m=0.5'.'m= 1 ','m=4','m=20')

Results

51

35

The Nakagami distnbution p (X )

251-

2- a i

52

Exercise 3.3.2

IMatlab program

% The Rice and Nakagami distribution

clear;k=2; • %the rice factor k =s''2/2b_0 x=0;0.01;3; %the time interval in seconds ohm_p= I ; %the total received power

p_elfa=(2.*x.*(k+l )/ohm_p).*exp(-k-({k+l).*x."'2/ohm_p)).*besseli(0,(2.*x.*sqrt(k*(k+l)/ohI■n_p)));plot(x,p_elfa)hold on

m=1.8;p_alphal=(2*m ''n i.*x .^(2*m -1 )/gamma(m)'''ohm_p''m).*exp(-m.*x.'^2/ohm_p);plot(x,p_aIphalhold offtitle('The Rice & Nakagami distribution p_{\alpha}(x)') xlabel('x')ylabelCp_{\alpha}(x)')legendCRice p_{\alpha}(.x) with k=2' , 'Nakagmi p_{\alpha}(x) with m=l .8')

Results

53

The Rice & Nakagami distnbution p (x)

Exercise 4.1

Matlab program

% Calculation o f simulation parameters

clearf_m=^91; % Maximal Doppler frequencyb= l; % Variance o f in-phase or quadrature componentN !=9; % Number o f sinusoids for the in-phase componentN2=10; % Number o f sinuosoids for the quadrature component

for n = l : l : N l ;c l{n)=sqrl(2*b/N Ỉ); fl (n)=f_m*sin(pi*(n-0.5)/(2*N 1)); th i(n)=2*pi*n/(N! + l);

end

for n = l ; l :N 2 ;c2(n)^sqrt(2*b/N2);í^(n)=fjĩi*sin(pi*(n-0.5)/(2*N 2));th2(n)=2*pi*n/(N2+l);

end

54

Solution 4

save ex4p l_R es n o cl c2 thl lh2 % these results will be used in the exercises 4.3 and 4.4

55

% a function which creates the deterministic % process g(t)% Save this function to a file name "g.m”

function y=g(c,f,th,t)

v~zeros(size(t)); for n=l :iength(f);

y==y+c{n)*cos(2*pi*f(n).*t+th(n));end;

Exercise 4.2

Matlah program

Excrcise 4.3

Matlab program

%-% Create a deterministic process by Rice method

clear;load ex4pl_R es f! t2 cl c2 th l th2

f_s-270800; % the carrier frequency in HertzT_sim -0.4; % simulation time in secondst-0 :l/f_s :T _sim ; % discrete time interval

g l= g (c l , f l , th l , t ) ; % generation o f the process gl by using the function “g.m' % from exercise 4.2

g2=g(c2,f2,th2,t);g=gl+j*g2;

alpha=abs(g);

56

a!pha_dB=20*logl0(aỉpha);plot(t,alpha_dB);litle(’Thc channel amplitude in ciB'); xlabel(T); ylabel(’\aỉpha(ty); legend('\alpha(t) in dB’,0);

Results

The channel ampUtude in đB

-20

-30

-40

57

Kxorcise 4.4

M atlab program

% Comparison o f Iheorelical Gaussian and Rayleigh % distribution with simulation results

dear;

load ex4pl_R es fl f 2 c l c 2 th l th2

r_s=500()0; % the carrier frequency in hertzT_sim=20; % simulation time in secondst-0:l/r_s:T_sim ;

g l= g (c l ,n , th l , t ) ;g2=g(c2,f2,th2,l);g=gl+j*g2;alpha=abs(g);g_mean=mean(g);g_variance=var(g);u l_m ean= m ean(g l);g 1 _variance=var(g ]);a iphajnean=m ean(alpha);alpha_variance=var(alpha);n=length(alpha);\=0:0.1:3; % the time interval in secondsb=hist(a!pha,x):

ngure(l);stem (\,b/n/(x(2)-x(l))); hold on;

k^O; % the rice factor k =s^2/2b_0ohm p=2; % the total received powerp_alpha=(2.*x.*(k+l)/ohm_p).*exp(-k-((k + 1 ).*x.^2/ohm_p)).*besscli(0,(2.*x.*sqrt(k*(k+l)/ohm_p)));plot(x.p_alpha,'f);tItleCThe F^DF o f alpha(xy);

58

xlabel('x');ylabel{'P_{\alpha}(x)');legend('p_{\alpha}(x)','Rayleigh distribution (Theory)'); hold oM

figure(2);

n l= length(g l) ;xl=-4:0.1;4; % the time interval in secondsc=hist(g l,x l);stem(x 1 ,c/n 1 /(x I (2)-x 1 (1))); hold on;p=(l/sqrt(2*pi))*exp(-xl. ’ 2/2);plot(xl,p,'r’);title(’The PDF o f g l process')xlabel('x');ylabelCP_{gl }(x)');legend('p_{gl }(x)','Gaussian distribution (Theory)'); hold off;

Results

59

07

0 5 ■

0 4

0 3

02

The PQF ol aipha(it)

/0Ni>

-o p,.(«)

R a y i« i^ cfcsirtjuiion (TN«fy>

1,

‘v<?

l i0 5 1 5 25

Rayleigh distribution (Theor> and result obtained by the channelsimulator)

03 5

0 3

0 25

0 2

0 05

Th* PDF of a ' process

9?

iGau»»ian diwnbuton (Th*ory)

9\

9\

Gaussian distribution (Theory and result obtained by the channelsimulator)

% = = = = = = = = = = = = = = = = = = = = = = = = = = ■ ■ =

% Autocorrelation result o f gl process

clear;

load ex4pl_R es fl o cl c2 thl th2

f_s=l 000; % the carrier frequency in hertz T_s=l/f_s; % sampling time in seconds Il = 10000*T_s;12=20000 *T_s;

t= ll:T_s:l2 ;

g l= g (c l , f l , th l , t ) ; phi_glg l=xcorr(g l, 'b iased ') ;1= 1:81; x = ( i - l ) * T _ s ;phi_g 1 g 1 _select=phi_g I g 1 (10001:10081);plot(x,phi_glgl_select);litleCThe autocorrelation function ACF o f g l');xlabel('\tau in seconds');y label(’\phi_{ g ig l} (\tau)');legend(’\phi_{glgl}(\tau) of gl');save ex4p5_Res phi__glgl _select f_s p h i_ g lg l;

60

Exercise 4.5

M atlab program

61

Results

The autocorrelation function ACF of g1

T in seconds

Excrcise 4.6

ỈVIatlab program

% Simulation result o f ACF o f g l in comparison with theoretical result

clear;f j n “ 91; % Maximum Doppler frequency b=l;N 1 ==9; % Number o f sinusoidstau ji iax = 0.08;t_a = 0.001; % Sampling interval for n = l :N i ;

cl(n)=sqrt(2*b/Ni);

62

fl (n)=f_m*sin(pi*(n-0.5)/(2*N 1)); th l(n)=2*pi*n/(N t + l);

end

tau=0:t_a:tau_max; k=l :length(tau); for n= l:N I

x(n,k)=(cl(n)^2/2)*cos(2*pi*fl{n).*tau);endfay=suin(x);

tau_s=-tau_max;t_a:tau_max; k=l :length(tau_s); for n=l -Nl

xs(n,k)=(cl(n)''2/2)*cos(2*pi*fl(n).*tau_s);endphi_g 1 g 1 _theory=sum(xs);

plot(tau,fay); hold on;f_c= 9 00e6 ; % T he ca rrie r frequency in H z

C_0=3e8; % The speed o f light in m/sv=109.2e3/3600; % The mobile station's speed in m/sf_m=v*f_c/c_0; % The maximum doppler frequencyohm_p=2; % The total received powert=0:0.001 :tau_max; % The time interval in seconds z=2*pi*f_m*t;phi_glgl=(ohm_p/2)*besselj(0,z); % The autocorrelation function plot(tau,phi_glgl,'r ')

load ex4p5_Res;N = length(phi _ g lg l ) ;p h i_ g lg l_ s = phi_glgl(N/2;N/2+tau_max/t_a)

plot(tau,phi_glgl_s,'k.')title('The autocorrelation function (ACF) o f the process g l ')xlabel('\tau in seconds')ylabel( '\phi_{glgl}(\tau)’)legend('\phi_{glgl }(\tau) Simulation model (Theory)','\phi_{gl g l }(\tau) Reference model', '\phi_{glgl }(\tau) Simulation') hold off

63

Results

The autocorreialion function (ACF) of the process gl

T in seconds

Comparison of the ACF o f the process g l generated by the channel simulator with reference model

Exercisc 4.8

Matlab program

% C o m pariso n o f the P S D o f the low -pass fading signal

% generated by the R ic e 's method w ith the reference P S D

clearfm =91; % D o pp ler frequency in H z

b - 1 ;

N l=9;r_l_n=fìn*sirì(pi*(( I ;N I )- l/2 )/(2 * N 1)); c _ l_ n = s q rt (2 * b /N l)* o n e s (s iz e (f_ l_ n ));

theta_I_n=2*pi*( 1 :N I )/(N 1 + 1);

fs= 10 0 0 ; % sam pling frequency

t_ s im = (1 0 E 3 :2 0 E 3 )/fs ; % time interval

g I_ t_ tild e = z e ro s (s iz e (t_ s im ));

for k = l: le n g t h ( f _ I_ n )

g l_ t_ t ild e = g l_ t_ t ild e + c _ l_ n (k )* c o s (2 * p i* f_ l_ n (k )* t_ s im + th e ta _ l_ n (k ));

end

r_g 1 _ g 1 = x c o rr(g 1 _t_t i lde,'biased');

P S D _ S = fft(r_ g l J g l ) ;

lc n _ S = le n g th (P S D _ S );

f_ P S D = (-(re n _ S -1 )/2 :(le n _ S -l )/2 )/le n _S »fs;

p lo t(f_ P S D ,fftsh ift(a b s(P S D _ S )/ie n _ S ),’b - ')

hold on

% --R efe ren ce m o d e l-

O m ega_p=2;

f= (-fm ): l :(fm );

S _ f= O m e g a _ p /2 /p i/fm ./sq rt( 1 -(f7fm ).*2);

p lo t ( f , S _ f > ’)

% --T h eo rectica l result o f sim ulation m o d e l-

f j i l d e _ n (N 1 1 •, 1 ) ,f _ l _ n Ị;

S_mm_tilde=-[c_l_n(N 1 1 : 1 ) .^2 ,cJ_n . ' '2 ] /4 ; S te m {f_tild e ,S _m m _tild e ,'m :x')

hold o ff

a x = a x is ;a x ( 1 ) = - 1 0 0 ;a x (2 )= 10 0 ;a x (3 )= 0 ;a x (4 )= 0 .0 8 ;a x is (a x )

legend( 'S im u latio n ','R e fe re n ce M odel', 'S im ulation M o d e l’)

x la b e l('D o p p le r fre q ue n cy, f in H z')

y la b e l( 'P S D ,S _ {g _ l g _ l } ( 0 ' )

64

R esults

65

0 08

i007Ị-

---------SimulationReference Model

ii- '» Simulation Model

0 06h

I

oo5r_ I

cn"

0 0 4 Ị-

7iX i

003 Ị-

0 02 !■’

ii 0 01Ị-••• - Ỉ ... 4.........L____

. i-100 -80 -60 -40 -20 0 20

Doppter frequency, f In H2

1 1Ị !

' 1

' 1

j

1 ' Ỉ i

i > i i

1 1 i

' 1 i » »il

hỊ 1

' 1

1 ' f 1 '

1 1 1 1 r h

ỊỈJ----------4 — Ỉ I MI 1. 1i 1 J t ) i Ỉ i40 60 80 100

P o w e r sp e c tra l d e n sity o f the s im u la tio n m odel

66

Solution 5

Exercise 5.1

Matlab program

% = = = = = = = = = = = = = =

% ỌPSK modulation% = = = = = = = = = = = = = =

clear;x=round(rand( 1,10000)); for i=l :2:length(x)

i fx ( i )= = 0 & x ( i+ l)= = 0 S((i+l)/2)=exp(j*pi/4);

elseif x(i)==0 & x(i+l )==1 S((i+l)/2)=exp(j*3*pi/4);

elseif x(i)==l & x(i+I)==l S((i+l)/2)=exp(j*5*pi/4);

e l s e i f x ( i ) = = l & X ( i+ 1 ) = = 0 S((i+l)/2)=exp(j*7*pi/4);

end end

save ex5pl_R es s x; % will be used in exercise 5.2

plot(S.'*'); hold on;

t=0:0.01:2*pi; p lo t(expO *t), 'r- ') ;

xlabel('\phi(t)');ylabel('S_m');litle('The complex signal-space diagram for4-ỌPSK');

Results

67

ThecoTf<«e» »gnaf-sp«c8 a» a g fa m o t4 -C ^S K

T-- r

-1 -08 -0 6 -0 4 -0.2 0 6 0 8 1

% = = = = = = = = = = = = = = = = = = = = = = = = = = = =

% ỌPSK modulation in presence o f noise% = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

68

Exercise 5.2

IMatlab program

clear;load e.\5pl_Res; % result from exercise 5.1

Es = var(S); % symbol energy

Eb=Es/2; % bit energySNR_db=6; % signal to noise ratio in dBN _0=E b/10 ''(SN R _db/10); N=sqrt(N_0/2)*(randn(size(S))+j*randn(size(S)));

R=s+N; % add noise to the signalplot(R,'.');hold on;

plot(S, 'r*'); hold on;

t=0;0.01:2*pi;p lo t(expO *t),V - ') ;iegend(’S_m','S');xtabel(T);ylabel('Q');title(The complex signal-space diagram o f 4-ỌPSK'); hold off;

Results

69

The com pieii s ignai-space ứag ram 0» 4 -O P S K

15

05

-0 5

-15

• s

•1 5 -OS 06 15

The complex signal-space diagram of QPSK in presence o f additive noise

Exercise 6.1

Matlab programs

% A function which demodulates the QPSK symbols % and counts the error bits % save this fimclion to a f i l e name "cha.m " % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

function y=clia(SNR_db,S,x)

Es=var(S); % Variance of ỌPSK symbols (Symbol energy)Eb=Es/2; % Bit energ>

ịvJk . N_0=Eb/10''(SNR_db/l0); % Noise variance in linear M N0=sqrt(N_0/2)*(randn(size(S))+j*randn(size(S)));

NS=S+NO;

theta in=[pi/4,3*pi/4,5*pi/4,7*pi/4]; s_m=e.\p(j*theta_m);

for i=l ;length(S) d=abs(S_m-NS(i)); ind=min(abs(Sjn-NS(i))); if md==d(l);

R(2*i-1)=0;R(2*i)=0;

elseit'md==d(2)R{2*i-1)=0;Fl(2*i)=l;

elseif md==d{3)R(2*i-l)=l;R(2*i)=l;

elseif md==d(4)R(2*i-l)=l;R(2*i)=0;

end

70

Solution 6

end

71

c=0; %Set the error counter to be zeros for i=l :length(x)

i fR ( i )~ = x ( i ) ;c = c + l ;

end end y=c;

% = = = = = = = = = = = = = = = = = = = = = = = =

% Main function o f the exercise 6.1% = = = = = = = = = = = = = = = = = = = = = = = =

;iear all;

load ex5pl_R es s x;% S; Transmitted Q PSK symbols % x: transmitted bit sequence SNR_db=0:2:8;% Signal to noise ratio

for i=l :length(SNR_db) c(i)=cha(SNR_db(i),S,x);

end

BEP=c/length(x); sem ilogy(SNR_db.BEP,'.- ') titie(’The bit error probability') xlabelCSNỈỈ in dB') ylabel(’P_b') legendCF^ b')save ex6pl_R es c BEF’ % will be used in the exercise 6.2

72

Results

10'

10*

10' -

10'

The bit error probability---------1--- ------

SNR in dB

The bit error probability o f a communication system using ỌPSK

Exercise 6.2

Matlah program

% Comparison o f simulation result o f bit error probability (BHP) % with theoretical results

clear;SNR_db=0:8; % Signal to noise ratio vector

SNR_db_simulalion=0:2:8;

for i=] :length(SNR_db)SNR(i)=10^(SNR db(i)/10);

73

uaiiima_b(i)^SNR(i);p_b(i)==erfc(sqrt(2*gamma_b(i))/sqil(2))/2;% Bi-J' o fQ P S K

endsemiloi;y(SNR_db.p_b,'ro—') liold onload e \6 p l_ R es c BEP; % Simulation result from exercise 6. semilogy(SNR_db_simulation. BEP,'x--’) titie(The bit error probabilitv') xlabciCSNR in diV)>iabel('P_b')leuend(Theory',’Simiilalion') liold off

Results

The brt error probability

10'

10SNR in dB

Comparison of the simulation with theoretical result

% A function which equalizes the received symbols according% a known channel then demodulates ỌPSK symbols% and counts the error symbols% Save this function to a file name "receiver, m " % = = = = = = = = = = = = = = = = = = = = = = = = = = = = : = = = = = = = = = = = =

function chann_l=receiver(SN R_db,S_m ,FS,x ,S ,g);Es=var(S); % Variance o f ỌPSK symbols (Svmbol energy)Eb=Es/2; % Eĩit energy N_0=Eb/l0 '^(SNR_db/10); % noise level in linear N0=sqrt(N_0/2)*(randn(size(FS))+j*randn(size(FS)));NFS=(FS+NO)./g; % received symbols after channel equalization

for i=] :length(FS)% calculate the distance o f the received symbol to all possible reference

symbols d=abs(S_in-NFS(i));

% ỌPSK demudulalion md=min(d); if md==d( I );

R(2*i-1)=0;R(2*i)=0;

elseif md==d(2)R(2*i-I)=0;R(2*i)=l;

elseif md==d(3)R (2 * i- l )= l;R(2*i)=l;

elseif md==d(4)R i2 * i- l )= l ;R(2*i)=0;

end

end

74

Exercise 6.3

M atlab program s

75

c "0; % set the counter o f the bit error to zero tor i=l :lentith(x)

if R ( i ) - ^ x(i);c = c + ] ; % increase the counter if an error occurs

end endchann l=c;

% Main function o f exercise 6.3

clear;load e \5 p l_ R es ; % result from the exercise 5.1 S-S( 1:20000); x=x( 1:40000);

%....................-...................................

% f^arameters for channel simulator% ------------------------------

t'_m=91; % maximum Doppler frequency in Hzb=l/2;N 1=9; % number o f sinusoids for simulation o f the imaginary partN2=N1 + 1; % number o f sinusoids for simulation o f the real part

n =f_m*sin(pi/2/N 1 *(( 1 :N 1)-1 /2)); c 1 =sqrt(2*b/N 1 )*ones(size(fl));

th 1 =rand(size(fl ))*2*pi; f2=f_m*sin(pi/2/N2*(( I :N2)-1 /2)); c2=sqrt(2*b/N2)*ones(size{t'2));

th2=rand(size(f2))*2*pi;

f_s=270800; % sampling frequency in hertz

T_symb=l/f_s; % the symbol duration

t-(0 :length(S)-1 )*T_symb; g l= g (c l , f l . th l , t ) ;

g2=g(c2.0,tli2,l);g=gl+j*g2;

FS=g.*S; % multiplying with fading channel

%...................................% Preparation o f reference symbols%.......-......................................^ ................

theta_m=[pi/4,3*pi/4,5*pi/4,7*pi/4]; s_m=exp(j * t heta_m); for i=l ;length(S)/4

gS_m(4*i-3:4*i)=S_m ,*g(4*i-3:4*i); end

SNR_db=0;5:30; for i=l :length(SNR_db)

c(i)=receiver(SNR_db(i),SjTi.FS.x,S,g):end

BEP=c/length(x);

save ex6p3_Res BEP; % for exercise 6.4

semilogy(SNR_db,BEP,title('The bit error probability o f QPSK over a fading channel')xlabelCSNR in dB')ylabel('f^_b')

76

Results

77

The bit error probability of QPSK over a fading channelT

15SNR in dB

Exercise 6.4

Matlab program

% BL: 1 o f ỌPSK over a fading channel

clear;b - i /2 ;SNR_db=0:5:30; %Signai to noise ratio

G am m aav e rag e = 2*b* 10.'^(SNR_db/l0);p_b -{1 -sqrt(Gamma_average./( 1 +Gamma_average)))/2;

78

semilogy(SNR_db,p_b,’r.--') hold onload ex6p3_Res BEP

semilogy(SNR_db,BEP;bo')

hold offtitle('BEP o f slow i1at Rayleigh fading channel’)xlabei(’\gamma_b')ylabe!(*ĩ^b')legend('BEP o f QPSK over a fading channel (Theory)',’- (Simulation)')

Results

10''BEP of s»ow flat Rayleigh fading channel

BEP of QPSK over a tađmg channel (Theory) o — (Simulation)

10’’b

£l" 10'

10 '' c

10'10 15 20 25 30

Comparison o f simulation with theoretical result

Exercise 7

Matlab programs

79

Solution 7

% A function performs ỌPSK demodulation, Viterbi decoding, % and calculation o f bit error probability% save this fiinciiori to a file name "chal.m ”%=

t'linction v=cha2{SNR db,S,meg,trellis) %for ex7

% QPSK Demodulation ::Es=var(S);Hb=Es/2;N_0=Eb/10"'(SNR_db/10);N0=sqrt(N_0/2)*(randn(size(S))+j*randn(size(S)));NS=S+NO;

theta_m=| pi/4,3 *pi/4,5* pi/4,7* pi/4]; s_m=exp(j*theta_m);

for i=l :leiiglh(S)

% calculate the distance o f the received symbol to all possible reference symbols

d=abs(S jn-N S(i));

% QPSK demodulation md=miii(d); if md==d(l);

R(2*i-i)=0;R(2*i)=0;

elseif md==d(2)R(2*i-1)=0;R(2*i)=l;

elscif md==d(3)R (2* i-l)= l;F<(2^i)=l;

elseif md==c1(4)

R(2*i-1)=!;R(2*i)-0;

endend

% :: Viterbi Decoderopm ode-trunc '; % the operation modedectvpe-hard '; % the representation type in the Code(\)£[0 1tblen-12; % the traceback depthr=vitdec{R,treilis.tblen,opmode,dectype);

80

% Calculation o f Bit Error Probability :: c=0;for i=l :length(r)

if r ( i ) - = meg{i) c=c+l;

end end y=c;

% Main program o f exercise 7

clear;k=3;R_c=l/2;

% '..Bit Sourcc:;meg=round(rand( 1,5000));% the input bit stream

% ::Convoluĩional Coder::conlen= 3; % constraintlength=k=l v=number o f shift registerscodegen=[7 5]; %codegenerator g ( l ) = ( l J , l ) - > 7 , g(2)=^{ 1,0,1 )->5 trellis=poly2trellis(conlen,codegen); x=convenc(meg.trellis); % the coded bit stream

% ::ỌPSK Modulation:: for i=l :2:length(x)

ifx ( i)= = 0 & x { i+ l)= = 0 S((i+l)/2)=exp0*pi/4);

elseif \(i)==() & x(i+ l)== l S((i-t 1 )/2)=c\p(j*3*pi/4);

clseif x(i)==l & x(i+ l)==l S((i+] )/2)=exp(j*5*pi/4);

elscif ,\(i)= = l & x ( i+ l)= = 0 S((i t l)/2)=exp(j*7*pi/4);

end end% s is the modulated complex signal

SNR_db=0:5;

for i=l :lengtli(SNR_db) c(i)=cha2(SNR_db(i),S,meg,trellis);% cha2 will demodulate,decode and

end %calculate the number o f errors in the% received signal

[ỉi;p=c/lenmh(meg);

semilogỵ(SNR_db.FíF.P.'.-') hold on

SNR_db=0:8;

load c.\6pl_Res % result from exercisc 6.1 Bl-P2=c/lent»th(x); soinilogy(SNR_db,BEP2,'r .-’) tille('The bit error probability')\l;ibcl('SNR in db') ylabel('P_b')lcucnd('i’_b wiui coder','P_b without coder') h d d o tf

82

Results

10'The bit error probability

- -- with coder bwrthou! coderb

10'

\ , V.\sV

\\

10*

104 5

SNR in eft)

Comparison o f BEP of a coded and uncoded system

83

Solution 8

K x crc ise 8.1

Matiiib programs

% Ol-DM modulator % NF!-T: FFT length % chnr: number o f subcarrier % (Ì; miard length% save this proịỊrưm to a filenam e "OFDhi_Modulator.m % for use in the main function

function [v] = OF-ĩ)M_Moduỉalor(data,NFFT,G);

chnr = len^th(data);N = Nf FT;

\ = |data,zeros( Ỉ ,N i’FT - chnr)]; %Zero padding

a - i r f t ( \ ) ; % n ty = [a(NFFl'-G+l :NFFT),a]; % insert the guard interval

% OFDM modulator % NFf-T: FFT length % chnr: number o f siibcarrier % G: guard length% N_P; channel impulse response length % save this program to a filename "OFDM J)emodulcitor.m % fo r use hi the main function

function [y] = ()FDM_Demodulator{data,chnr.NF FTX));

"/0Ố insert the guard interval\_remove_guard_interval = [data(G+l :NFFT+G)];

84

X = f f t (x _ rem o v e_ g u a rd _ in lerv a l) ;

y = x(l :chnr); %Zero removing

% Main function o f exercise 8.1

clear all;

NFFT = 64; % FFT lengthG = 9; % Guard interval length

M_ar>' =16; % Multilevel of M-ary symbol

t_a = 50* 10^(-9); % Sampling duration o f HiperLAN/2

load rho.am -ascii; % load discrete multi-path channel profile

h = sqrt(rho);

N_p = length(rho);

H = fft([h,zeros(l,NFFT-N_P)]);

NofOFDMSymbol = 100; % Number o f OFDM symbols

ienglh_dala - (NofOFDM Sym bolj * NFFT;% The total data length

%.....................

% Source bites %................source_data = randint(leni»th_data,sqrt(M_ary));

% ..........................................-

% bit to symbol coder% - ........ — — -

symbols = bì2de(source_daía);

85

%-% Q)AM modulator in base band% .............................................................................. - ...................................................................................................

QAM_Syinbol = dmodce(symbols, ỉ,l,'qam\M_ary);

%-% Preparing data pattern0//0-

Data Patlern ^ (]; % Transmitted Signal before IFFT

for i=0:NofC)p[3MSymbol-l;Q A M je m = []; for n=l:NFFT;

Q A M je m = [QAM_tem,QAM_Symbol(i*NFFT+n) end;Dala_Paltern = [Data_Pattern;QAM_tem];

clear QAM_tcm;

end;

ser = []; % Set the counter o f symbol error ratio to be a empty vector

snr_min =0; snrjiiax =25; step = I ;for snr = snr_min:step:snr_max;

snr = siir - 10*1o r U)((NFFT-G)/NFFT); %Miss matching effect

rs_frame = []; % A malrix o f received signal

for i=0:Nof'OFDMSymbol-l;

% OFDM modulator

OFDM_signal_tem = OFDM_Modulator(Data_Pattern(i+K:),NFFT,G);

% The received signal over multi-path channel is created by a % co n v o lu t io n a l operation

86

rs = conv(OF'I)M_signal_tem, h);

% Additive noise is added

rs = avvgn(rs.snr,’measured','dB');

rs_fram e= [rs_frame; rs|;

clear OFDM_signal_tem; end;

%...................

% Receiver % .............. -

Receiver_Data = []; % Prepare a matrix for received data symbols

d = []; %Demodulated symbols data_symbol = [];

for i=l :NofOFDMSymbol; i f ( N _ P > G + l ) & 0 > l )

% if it is nol the first symbol and the length o f CI R is longer than % the gaurd interval length, then the IS! term must be taken into % accountprevious_symbol = rs_frame(i-l,:);

% previous OFDM symbol

IS iJc rm = previous_symbol(NFFT+2*G+l :NFFT+G+N_P-1);% the position from N FFT+2G +1: NFFT+G+N_P-1 is IS! ttrm

ISỈ = [ISI_term,zeros(l Jength(previoiis_svmbo!)-lcngih(ISI_term))];

rs_i " rs_frame(i,:) + ISl;

% the IS! term is added to the current OFDM symbolelse

r s j = rs_frame(!,:);

87

end;

%•% OFDM deniodiilator%... ....... ..................................l)emodulated_signal_i = OFDM_Demodulator(rs_i,NFFT,NFFT,G);

%■% O F D M i:quaiization%................... -....... -.........d = Demodulated_signai__i./H;

d e m o d u la le d s y m b o l j = ddemodce(d, lJ , 'Q A M ',M _ary);

data_svmboi = [data symbol, demodulated_svmbol_iJ;

end;

d a ta _ sv m b o ! = data_svm bol';

^C alcu la tion o f error symbols I number, ratio] = symerr(symbols,data_symbol);

ser = [ser, ratio];

end;

snr = snr min:stcp:snr max;

scinilouyisiir, ser,'bo');

ylabeiCSER’); xIaheK’SNR in ciB');

88

Result

SER of an OFDM svstem over a multi-path channel

Exercise 8.2

R e su lts

10'

10'

10

o

o G = 9• G = 0

89

10 15 20 25SNR in dB

Comparison o fS E R o f an OFDM system with and without guard interval

90

Exercise 8.3

M atlab program s

% Monte Carlo method for a time-variant channel modelliiiu % save ihis program io a file name "MCM_cỉìannc! model, m " % for use in the main function

function [h.t_next] = MCM_channeljTiodcl(Li. inilial_tinic. number_of_summations. symbol_duration, f_dmax. channcl coefilcients);

t = initialjime;

Channe!_Lcimth = lenuth(channel_coefncients);

h_vector “ [];

for k=l :Channel_Lcngtii;Ii_k = u(k,:); % A randt')m variablephi = 2 * pi * u_k; % Phase coefficients are createdf_d - f_dmax * sin(2*pi*u_k); % Doppler frequency after Monte Carlo

method is created

h_lem^channel_coefficients(k)* ỉ/(sqrt(number_of_summations))*suin(exp(j *phi).*exp0*2*pi*f_d*t));

h _ v ecto r = [h _vcc tor , h j e m j ; end;

h “ h_vccu>r;I j iex t = initialjim c + symbol_duration; %Coherent time for the next syinboi

% Main function: Of'DM system over a time-variant channel

clear all;

NFFT = 64; % FFT length

91

(i - 9: % Guard intervai iengtli

M_ar\ =16; % Multilevel o f M-ary symbol

I a = 50* % Sampling duration o f I ỉiperLAN/2

load rho.am -ascii; % load discrete miilti-palh channel profile

N_p = ienuth(rho); % Leni;th oi'channel impulse response (CỈR)

‘'o-% Parameters for Monte Carlo channel

symbol_duration = NFFT * t_a; % OFDM symbol duration niimber_of_summalions = 40;% Number o f summations for Monte-Carlo method

fjdm ax = 50.0; % Maximum Doppler frequency in Hz

NolOi DMSvmboi = 1000; % Number o f OFDM symbols

lcngth_data = (Nol'OF[)MSymbol) * NFFT;% The total data length

%•% Source bites%..........source data = randintiicnglh_data,sqrt(M_ary));

%■% bit to symbol coder% ........ — .........

symbols = bi2de(soLirce_data);

%— -....................................” 0 ỌAM modulator in base band %..............................................

QAM_Symbol = dmodce( symbols, lJ , 'q am ’,M_ary);

%.....................-...............-..........................

% Preparing data pattern% ........ ^ .... -............. .......

Dala_Pattern = []; % Transmitted Signal before IFFT

for i=0:NofOFDMSymbol-l;QAM_tem = []; for n=l:NFFT;

QAM_tem = [ỌAM_tem,ỌAM_Symboỉ(i*NFFT+n) end;Data_Pattern = [Data_Pattern;QAM Jem ];

clear Q A M jem ; end;

Number_Relz = 50; ser_relz = [];for number_of_relialization“ I : Number_Relz;

u = rand(N_P,number_of_summations);% A random variable for Monte-Carlo method

92

ser = []; % Set the counter of symbol error ratio to be a empty vector

snr_min =0; % minimum of SNR in dB snr_max =25;% maximum of SNR in dR step = 1;for snr = snr_min:step:snr_ma\;

s n r - s n r - 10*logl0((NFFT-G)/NFFT);

%Miss matching effect caused by using guard interval

rs_frame = []; % A matrix of received signalh_frame = []; % A matrix of the Cl Rinitial_time = 0; % initial time for time-variant channel modelling

for i =0:NofOFDMSymboI-l;

93

% ()F-'Ị)M modulator

OF[)M_signaỉ_tem = OFDM _Modulator(Data_Pattern(i+l,:).NFFT,G);

[h, I] = MCM_channel_model(u, initial_time, number__of_summations,Hnibol_cỉuration......

f_dmax. rho); % Monto-Carlo channel modelling

h frame = [h_frame; h];

% The received signal over multhipath channel is created by a % co n v o ỉu t io n a ỉ operation

rs = conv(OFDM_signal_tem, h);

% Additive noise is added

rs = a\vgn(rs,snr,'measurecl','dB');

rs_frame - [rs_frame; rs];

in it ia l j im e = t;

clear OM)M_signal_tein; end;

% Receiver 0//0-------------

keceiver_Data = []; % Prepare a matrix for reveived data symbols

d = []; % Equalized symbolsdata_symbol = [|; % a vector o f demodulated symbols

lor :Not'OFDMSymbol; i f ( N _ P > G + ] ) & ( i > l )

% if it is not the first symbol and the length o f CỈR is longer than % the gaurd interval leniỉth, then the ISỈ term must be taken into

94

% accountprevious_symbol = rs_frame(i-l,:);

% previous OFDM symbol

IS!_terni = previous_symboi(NFFT+2*G+ 1 :NI'[T+G^ N _P-1);% the position from NFFT+2G + 1: NFFT+G+N_P-1 is !SI term

ỈSI = [ISI_term,zeros{ ],length(previous_symbol)-lentith(lSI term))];

r s j = rs_frame{i,:) + IS!;

% the IS! term is added lo the current OFDM symbo!else

rs_i = rs_frame(i,:);

end;

%.................................................................................................% OFDM demodulator% ......................................................- ............................................................................................................................. - ...........................................

Demodulated_signal_i = Oi*DM_Demodulator(rs_i,NFF” r ,N i 'F l ’,G);

%...........................................% O FD M Equalization %...................-..................

h ~ h _fram eii,:); % CIR corresponds to i-th O F i^M sy m b o l

fl - fft([h,zeros(l,NFFT-N_P)]);% correspondini> channel transfer function

d = Demodulaled_signalj./H; % equalized symbol

demodiilated_symbol_i = ddemodce(d, 1,1 ,’Ọ AM \M _ary);

data_symbol = [clata_svmbol, demodulated_svmbol j ] ;

end;

95

Jata_sym b()l “ d a ta _ sy m b o r;

%Calculation of error symbols[number, ratio] = symerr(symbols,data_symbol);

ser = [ser, ratio];

end;

ser_relz - (ser relz;ser]; end;

ser = sum(ser_relz)/Number_Relz;

snr = snrjiiin:slep:snr_m ax;

semilogv(snr, ser,’bo');

ylabel('SER’); xlabelCSNR in dB');

96

Results

10

10'

i ’o-’

10'

10 '

o• o

o Time-invariant channel. L __= 0

« Time-variant channel, __ = 50 Hz’ Om«x

10 15SNR In dB

20 25

Comparison o f SER of an OFDM system over a time-invariant channel with that over a time-variant channel

97

Các tác giá có nhận tồ chức các khoá học theo chương trình như đã

trình bày trong quyển sách này cho các viện, các trilờng đại học và các

tổ chức khác.

Do đây là lần xuất bán đầu, cuốn sách này không tránh khỏi những

thiếu sót, Các tác giá xin chân thành cám ơn các ỷ kiến đóng góp cho

cuốn sách này để chất luợng cuốn sách trong những tái bản lần sau

được tốt hơn,

Thư liên lạc với các tác giả xin gửi về: [email protected]

98

Digital Communication Technique

Band 1

Matlab Exercises for Wireless Communications

Responsible for Publishing:

Publishing Editor:

Cover design:

Prof. Dr. TO DANG HAI

MSc. NGUYEN HUY TIEN

NGUYEN HUONG LAN

Science and Technics Publishing House

70, Tran Hung Dao Str., Hanoi, Vietnam

Publishing Licence No: 6-355, dated 30/12/2004.

Quantity: 700 PCs, Size 16x24 cm.

Printed at 19/8 Printing Company.

Printing finished and copyright deposited in January 2005

99

Bộ sách Kỹ thuật thông tỉn số

T ậpl

Các bài tập Matlab về Thông tin vô tuyến

Tác giả: Cheng - Xiang Wang, Nguyễn Văn Đức

Chịu trách nhiệm xuất bản; PGS. TS. Tô Đảng Hài

Biên lập và sửa bài: ThS. Nguyễn Huy Tiến

Ngọc Linh

Trình bày bìa; Nguyễn Hương Lan

KM)

NHÀ X UÁT BẢN KHOA HỌC VÀ KỸ THUAT

70 TRÀN HUNG ĐẠO HÀ NOI

In 700 cuốn, khổ 1 6 x 2 4 c m , tại Xí nghiộp in 1

Giấy phép xuất bán sổ: 6-355- 30' 12/2004

In xong và nộp lưu chiểu tháng 1 năm 2005.


Recommended