You are on page 1of 718

SIMULINK

Communications Toolbox
Modeling
Simulation
Implementation
Users Guide
Version 2

Weizheng Wang
How to Conta ct The Ma thW orks:
508-647-7000 Phone
508-647-7001 Fax
The MathWorks, I nc. Mai l
24 Pri me Park Way
Nati ck, MA 01760-1500
ht t p: //www. mat hwor ks . com Web
f t p. mat hwor ks . com Anonymous FTP ser ver
c omp. s of t - s y s . mat l ab Newsgroup
s uppor t @mat hwor ks . com Techni cal support
s ugges t @mat hwor ks . com Product enhancement suggesti ons
bugs @mat hwor ks . com Bug r epor ts
doc@mat hwor ks . com Documentati on err or r epor ts
s ubs cr i be@mat hwor ks . com Subscr i bi ng user r egi strati on
s er v i ce@mat hwor ks . com Or der status, l i cense renewal s, passcodes
i nf o@mat hwor ks . com Sal es, pr i ci ng, and gener al i nformati on
Communications Toolbox Users Guide
COPYRI GHT 1996 - 1997 by The MathWor ks, I nc. Al l Ri ghts Reser ved.
The softwar e descr i bed i n thi s document i s fur ni shed under a l i cense agr eement. The softwar e may be used
or copied onl y under the ter ms of the l i cense agr eement. No par t of thi s manual may be photocopi ed or r epr o-
duced i n any for m wi thout pr i or wr i tten consent fr om The MathWorks, I nc.
U.S. GOVERNMENT: I f Li censee i s acquir i ng the softwar e on behal f of any uni t or agency of the U. S.
Gover nment, the fol l owi ng shal l appl y:
(a) for uni ts of the Depar tment of Defense:
RESTRI CTED RI GHTS LEGEND: Use, dupli cation, or discl osur e by the Gover nment is subject to r estr i c-
ti ons as set for th i n subparagraph (c)(1)(i i ) of the Ri ghts i n Techni cal Data and Computer Software Cl ause
at DFARS 252.227-7013.
(b) for any other unit or agency:
NOTI CE - Notwi thstandi ng any other l ease or li cense agr eement that may pertai n to, or accompany the
del iver y of, the computer softwar e and accompanyi ng documentati on, the r ights of the Gover nment
r egar ding i ts use, repr oducti on and discl osur e ar e as set for th i n Clause 52.227-19(c)(2) of the FAR.
Contractor /manufactur er i s The MathWor ks I nc., 24 Pr i me Par k Way, Nati ck, MA 01760-1500.
MATLAB, Si muli nk, Handle Gr aphi cs, and Real -Ti me Wor kshop ar e r egi ster ed trademar ks and Statefl ow
and Tar get Language Compi ler ar e tr ademar ks of The MathWor ks, I nc.
Other pr oduct or br and names are tr ademar ks or r egister ed tr ademar ks of thei r r espective hol ders.
Pr i nti ng Hi stor y: Apr i l 1996 Fi rst pri nti ng
May 1997 Second pr i nti ng (for MATLAB 5)

FA X
u
@
i
Contents
1
Before You Begin
What I s the Communi cati ons Tool box? . . . . . . . . . . . . . . . . . . . 1-2
Avai l abl e Functi ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Rel ated Pr oducts and Documentati on . . . . . . . . . . . . . . . . . . . . 1-3
What i s MATLAB? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
What i s the Si gnal Processi ng Tool box? . . . . . . . . . . . . . . . . 1-3
What i s Si mul i nk? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
Recommended Pr oducts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
I nstal l ati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5
Usi ng the Tool box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5
Or gani zati on of thi s Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6
Acknowl edgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
2
Introduction to Communication Systems
The Parts of a Communication System . . . . . . . . . . . . . . . . . . 2-3
The Communi cati ons Tool box Bl ock Li brar y . . . . . . . . . . . . . . . 2-4
MATLAB Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8
Differences Between Simulink and MATLAB Simulation 2-10
Data Fl ow Si mul ati on Exampl e . . . . . . . . . . . . . . . . . . . . . . . . 2-10
Ti me Fl ow Si mul ati on Exampl e . . . . . . . . . . . . . . . . . . . . . . . . 2-12
Compari son of Ti me and Data Fl ow Si mul ati on Schemes . . . 2-14
ii Contents
3
Tutorial
Signal Generators and Display Devices . . . . . . . . . . . . . . . . . 3-5
Random Si gnal Gener ators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
Gaussi an Noi se Generator . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
Rayl ei gh Noi se Generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
Ri ci an Noi se Generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
Poi sson Random I nteger Generator . . . . . . . . . . . . . . . . . . . . 3-7
Uni form Noi se Generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7
Di spl ay Devi ces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7
Eye-Pattern Di agr ams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8
Scatter Pl ots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11
Err or-Rate Anal ysi s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12
Source Coding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13
Scal ar Quanti zati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-13
Tr ai ni ng of Par ti ti on and Codebook Parameters . . . . . . . . . 3-16
Companders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-18
-l aw Compander . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-18
A-l aw Compander . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-19
Pr edi cti ve Quanti zati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-19
Di fferenti al Pul se Code Modul ati on . . . . . . . . . . . . . . . . . . . 3-20
Error-Control Coding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-23
Vector vs. Sequenti al I nput/Output . . . . . . . . . . . . . . . . . . . . . 3-25
Vector I nput/Output For mat . . . . . . . . . . . . . . . . . . . . . . . . . 3-26
Sequenti al I nput/Output For mat . . . . . . . . . . . . . . . . . . . . . 3-27
Err or -Contr ol Codi ng Li brar y Bl ocks . . . . . . . . . . . . . . . . . . . . 3-29
Li near Bl ock Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-30
Exampl e of a Li near Bl ock Code . . . . . . . . . . . . . . . . . . . . . . 3-32
Hammi ng Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-32
Cycl i c Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-33
BCH Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-33
BCH Encodi ng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-34
BCH Decodi ng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-36
Reed-Sol omon Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-36
iii
Convol uti onal Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-37
The Tr ansfer Functi ons of Convol uti onal Codi ng . . . . . . . . 3-38
Convol uti onal Encodi ng . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-44
Convol uti onal Decodi ng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-44
Exampl e of Convol uti onal Decodi ng . . . . . . . . . . . . . . . . . . . 3-48
Modul ati on and Demodul ati on . . . . . . . . . . . . . . . . . . . . . . . . . 3-52
Passband Anal og Modul ati on and Demodul ati on . . . . . . . . . . 3-53
Exampl e of the Effect of Lowpass Fi l ter s on Demodul ati on 3-54
Doubl e-Si deband Suppr essed Car ri er Ampl i tude
Modul ati on and Demodul ati on . . . . . . . . . . . . . . . . . . . . . . . 3-56
Doubl e-Si deband wi th Tr ansmi ssi on Car ri er Ampl i tude
Modul ati on and Demodul ati on . . . . . . . . . . . . . . . . . . . . . . . 3-57
Si ngl e-Si deband Suppr essed Carr i er Ampl i tude
Modul ati on and Demodul ati on . . . . . . . . . . . . . . . . . . . . . . . 3-60
Quadrature Ampl i tude Modul ati on and Demodul ati on . . . 3-62
Fr equency Modul ati on and Demodul ati on . . . . . . . . . . . . . . 3-65
Phase Modul ati on and Demodul ati on . . . . . . . . . . . . . . . . . 3-66
Passband Di gi tal Modul ati on and Demodul ati on . . . . . . . . . . 3-67
Types of Di gi tal Modul ati on/Demodul ati on . . . . . . . . . . . . . 3-69
M-ary Ampl i tude Shi ft-Keyi ng Modul ati on . . . . . . . . . . . . . 3-71
M-ary Quadr ature Shi ft-Keyi ng Modul ati on . . . . . . . . . . . . 3-73
Square Constel l ati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-74
Ci rcl e Constel l ati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-75
Arbi trar y Constel l ati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-76
M-ary Fr equency Shi ft-Keyi ng Modul ati on . . . . . . . . . . . . . 3-80
Coherent Demodul ati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-81
Noncoher ent Demodul ati on . . . . . . . . . . . . . . . . . . . . . . . . . 3-82
Si mul i nk Exampl e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-84
MATLAB Exampl e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-86
M-ary Phase Shi ft-Keyi ng Modul ati on . . . . . . . . . . . . . . . . . 3-87
Baseband Modul ati on and Demodul ati on . . . . . . . . . . . . . . . . 3-89
Baseband Anal og Modul ati on . . . . . . . . . . . . . . . . . . . . . . . . . . 3-90
Baseband Anal og Demodul ati on . . . . . . . . . . . . . . . . . . . . . . . . 3-92
Coherent Demodul ati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-92
Noncoher ent Demodul ati on . . . . . . . . . . . . . . . . . . . . . . . . . 3-93
Baseband Di gi tal Modul ati on . . . . . . . . . . . . . . . . . . . . . . . . . . 3-93
Baseband Di gi tal Demodul ati on . . . . . . . . . . . . . . . . . . . . . . . . 3-97
Usi ng the Baseband Si mul ati on Functi onal i ty
i n the Tool box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-97
Baseband Si mul ati on Exampl e . . . . . . . . . . . . . . . . . . . . . . . 3-99
iv Contents
Signal Multiple Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-104
Ti me-Shar e Mul ti pl exi ng and Demul ti pl exi ng . . . . . . . . . . . 3-104
Vector Si gnal Redi stri buti on . . . . . . . . . . . . . . . . . . . . . . . . 3-106
Ti me Di vi si on Mul ti pl e Access (TDMA) . . . . . . . . . . . . . . . . . 3-107
Di gi tal TDMA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-107
Fr equency Di vi si on Mul ti pl e Access (FDMA) . . . . . . . . . . . . . 3-108
Code Di vi si on Mul ti pl e Access (CDMA) . . . . . . . . . . . . . . . . . 3-110
Transmitting and Receiving Filters . . . . . . . . . . . . . . . . . . . 3-113
Rai sed Cosi ne Fi l ter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-113
Rai sed Cosi ne Fi l ter Exampl e . . . . . . . . . . . . . . . . . . . . . . . 3-116
Si nc Fi l ter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-118
Hi l bert Transform Fi l ter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-118
Channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-120
Passband Channel s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-120
Baseband Channel s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-121
Rayl ei gh Noi se Channel . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-121
Ri ci an Noi se Channel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-121
Fadi ng Channel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-121
Synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-123
Passband Si gnal PLL Si mul ati on . . . . . . . . . . . . . . . . . . . . . . 3-123
Baseband Si gnal PLL Si mul ati on . . . . . . . . . . . . . . . . . . . . . . 3-125
Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-126
Vol tage Contr ol l ed Osci l l ator . . . . . . . . . . . . . . . . . . . . . . . . . 3-127
Modul o I ntegr ator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-127
Wi ndowed I ntegr ator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-128
Schedul ed Reset I ntegrator . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-128
Mi ni mum/Maxi mum I ndex . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-128
Arr ay Functi ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-128
Scal ar to Vector Conver ter . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-128
Vector to Scal ar Conver ter . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-129
Modul o Operati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-129
Mean and Var i ance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-129
Galois Field Calculations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-130
Gal oi s Fi el d, GF(q) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-130
v
Pol ynomi al s over GF(q) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-131
GF(q
M
), the GF(q) Fi el d Extensi on . . . . . . . . . . . . . . . . . . . . . 3-132
Addi ti on i n GF(q
M
) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-136
Mul ti pl i cati on i n GF(q
M
) . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-136
The Cycl otomi c Cosets of GF(q
M
) . . . . . . . . . . . . . . . . . . . . 3-137
Mi ni mal Pol ynomi al s over GF(q
M
) . . . . . . . . . . . . . . . . . . . 3-137
The Roots of Pol ynomi al s over GF(q
M
) . . . . . . . . . . . . . . . . 3-138
Other GF(q) Rel ated Functi ons . . . . . . . . . . . . . . . . . . . . . . . . 3-138
4
Examples
Bit-Error Rate Computation . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
Backgr ound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
Open the COMMGUI Wi ndow . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
Digital Subscriber Telephone Lines (DSL) . . . . . . . . . . . . . . . 4-7
Channel and Noi se Model s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-8
The Tr anscei ver Ar chi tecture . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-9
Per for mance Si mul ati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10
The Recei ver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12
Refer ences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-14
Early-Late Gate Synchronization . . . . . . . . . . . . . . . . . . . . . . 4-15
Backgr ound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-15
Communi cati on System Si mul ati on . . . . . . . . . . . . . . . . . . . . . 4-18
Si gnal Si mul ati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-19
Communi cati ons Channel . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-20
Si gnal Demodul ati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-21
V.34 Modem Data Transmission . . . . . . . . . . . . . . . . . . . . . . . 4-29
Backgr ound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-29
Si mul ati on Bl ock Di agram . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-30
Parameter s and Li mi tati ons of the Si mul ati on Desi gn . . . . . . 4-33
vi Contents
Cal l Modem Si mul ati on I mpl ementati on . . . . . . . . . . . . . . . . . 4-36
Scr ambl e, Par ser, and Shel l Mappi ng Subsystem . . . . . . . . 4-37
Di fferenti al Encoder Subsystem . . . . . . . . . . . . . . . . . . . . . . 4-37
Rotati on Subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-38
Pr ecoder Subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-39
Nonl i near Encoder Subsystem . . . . . . . . . . . . . . . . . . . . . . . 4-39
Synchroni zati on Pul ses Subsystem . . . . . . . . . . . . . . . . . . . 4-39
Tr el l i s Code Subsystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-40
Answer Modem Si mul ati on I mpl ementati on . . . . . . . . . . . . . . 4-44
5
MATLAB Function Reference
Formats and Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3
Reference Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4
6
Simulink Block Library Reference
Sources and Sinks in Communication Systems . . . . . . . . . . . 6-4
Sour ces and Si nks Reference Tabl e . . . . . . . . . . . . . . . . . . . . . . 6-6
Source Coding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-38
Sour ce Codi ng Refer ence Tabl e . . . . . . . . . . . . . . . . . . . . . . . . . 6-39
Error-Control Coding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-53
Err or -Contr ol Codi ng Refer ence Tabl e . . . . . . . . . . . . . . . . . . . 6-54
Modulation and Demodulation . . . . . . . . . . . . . . . . . . . . . . . 6-110
Anal og Modul ati on/Demodul ati on Methods
for Passband Si mul ati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-111
Anal og Modul ati on/Demodul ati on
Passband Reference Tabl e . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-114
vii
Anal og Modul ati on/Demodul ati on
Methods for Baseband Si mul ati on . . . . . . . . . . . . . . . . . . . . . 6-134
Anal og Modul ati on/Demodul ati on
Baseband Reference Tabl e . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-136
Di gi tal Modul ati on/Demodul ati on
Methods for Passband Si mul ati on . . . . . . . . . . . . . . . . . . . . . 6-153
Di gi tal Modul ati on/Demodul ati on
Passband Reference Tabl e . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-155
Di gi tal Modul ati on/Demodul ati on
Methods for Baseband Si mul ati on . . . . . . . . . . . . . . . . . . . . . 6-183
Di gi tal Modul ati on/Demodul ati on
Baseband Reference Tabl e . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-185
Mappi ng/Demappi ng for Di gi tal Modul ati on/Demodul ati on . 6-207
Passband and Baseband Di gi tal
Mappi ng/Demappi ng Reference Tabl e . . . . . . . . . . . . . . . . . . 6-211
Signal Multiple Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-235
Mul ti pl e Access Reference Tabl e . . . . . . . . . . . . . . . . . . . . . . . 6-237
Transmitting and Receiving Filters . . . . . . . . . . . . . . . . . . . 6-249
Tr ansmi tti ng/Recei vi ng Fi l ter s Reference Tabl e . . . . . . . . . . 6-250
Channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-261
Channel Refer ence Tabl e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-262
Synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-275
Synchroni zati on Refer ence Tabl e . . . . . . . . . . . . . . . . . . . . . . 6-276
Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-285
Uti l i ty Reference Tabl e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-287
A
RTW and Communications
Template Makefiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-3
Updati ng the Templ ate Makefi l e for the Tool box . . . . . . . . . A-3
viii Contents
Example: TCM Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-5
RTW Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-9
Wr i ti ng MEX-Fi l e S-Functi ons for RTW . . . . . . . . . . . . . . . . . . A-9
Bl ock Names and Code Generati on . . . . . . . . . . . . . . . . . . . . . . A-10
Limitations And Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-11
B
Bibliography

1
Before You Begi n
What Is the Communications Toolbox? . . . . . . . . 1-2
Related Products and Documentation . . . . . . . . 1-3
Installation. . . . . . . . . . . . . . . . . . . . . 1-5
Using the Toolbox. . . . . . . . . . . . . . . . . . 1-5
Organization of this Manual . . . . . . . . . . . . . 1-6
Acknowledgments . . . . . . . . . . . . . . . . . 1-7
1 Before You Begin
1-2
Thi s chapter pr ovi des a bri ef over vi ew of the Communi cati ons Tool box. I t
expl ai ns how to use thi s gui de and poi nts you to addi ti onal manual s for
i nfor mati on on i nstal l ati on, the worki ng envi r onment, and rel ated products.
What Is the Communications Toolbox?
The Communi cati ons Tool box i s a col l ecti on of computati on functi ons and
si mul ati on bl ocks for r esearch, devel opment, system desi gn, anal ysi s, and
si mul ati on i n the communi cati ons ar ea. The tool box i s desi gned to be sui tabl e
for both experts and begi nners i n the communi cati ons fi el d. The tool box
contai ns ready-to-use functi ons and bl ocks, whi ch you can easi l y modi fy to
i mpl ement your own schemes, methods, and al gori thms. The Communi cati ons
Tool box i s desi gned for use wi th MATLAB

and Si mul i nk

.
The Communi cati ons Tool box i ncl udes:
Si mul i nk bl ocks
MATLAB functi ons
You can use the tool box di r ectl y fr om the MATLAB workspace. You can use the
Si mul i nk envi ronment to constr uct a si mul ati on bl ock di agram for your
communi cati on system. For conveni ence, the Communi cati ons Tool box
pr ovi des onl i ne i nter acti ve exampl es that use many of the functi ons found i n
thi s tool box.
Ava i la ble Functions
Thi s tool box supports a var i ety of functi ons i n the communi cati ons ar ea. These
functi ons i ncl ude:
Data source
Sour ce codi ng/decodi ng
Err or-control codi ng
Modul ati on/demodul ati on
Transmi ssi on/recepti on fi l ter s
Transmi tti ng channel
Mul ti pl e access
Synchroni zati on
Uti l i ti es
1-3
Related Products and Documentation
The Communi cati ons Tool box requi r es:
MATLAB
The Si gnal Processi ng Tool box
W ha t is M ATLAB?
MATLAB i s a power ful col l ecti on of tool s for al gor i thm devel opment,
computati on, and vi sual i zati on. I t provi des mor e control and fl exi bi l i ty
compar ed to a tradi ti onal hi gh-l evel progr ammi ng l anguage. Unl i ke such
l anguages, MATLAB i s compact and easy to l ear n, l etti ng you express
al gor i thms i n conci se, r eadabl e code. I n addi ti on, MATLAB provi des an
extensi ve set of ready-to-use functi ons i ncl udi ng mathemati cal and matr i x
oper ati ons, gr aphi cs, col or and sound contr ol , and l ow-l evel fi l e I /O. MATLAB
i s readi l y extensi bl e you can use the MATLAB l anguage to easi l y cr eate
functi ons that operate as par t of the MATLAB envi ronment.
Note: The Communi cati ons Tool box r equi r es versi on 4.2c or l ater of
MATLAB.
The Using MATLAB gui de descr i bes how to work wi th the MATLAB l anguage.
I t di scusses how to enter and mani pul ate data and use MATLABs extensi ve
col l ecti on of functi ons. I t expl ai ns how to per for m command-l i ne computati ons
and how to cr eate your own functi ons and scri pts. The onl i ne MATLAB
Functi on Reference pr ovi des reference descri pti ons of suppl i ed MATLAB
functi ons and commands.
W ha t is the Signa l Processing Toolbox ?
The Si gnal Pr ocessi ng Tool box i s a col l ecti on of tool s bui l t on the MATLAB
numeri c computi ng envi r onment. The tool box supports a wi de range of si gnal
processi ng oper ati ons, from waveform gener ati on to fi l ter desi gn and
i mpl ementati on, par ametri c model i ng, and spectr al anal ysi s.
The Signal Processing Toolbox Users Guide descri bes the tool box i n detai l . I t
di scusses how to use the tool box functi ons to address a var i ety of si gnal
processi ng tasks, and pr ovi des tutor i al i nformati on, exampl es, and i ndi vi dual
functi on r efer ence pages.
1 Before You Begin
1-4
Note: The Communi cati ons Tool box requi res versi on 3.0b or l ater of the
Si gnal Processi ng Tool box.
W ha t is Si mulink?
Si mul i nk i s a dynami c system si mul ati on envi r onment. I t al l ows you to
r epr esent systems as bl ock di agr ams, whi ch you bui l d usi ng your mouse to
connect bl ocks and your keyboar d to edi t bl ock par ameters. The
Communi cati ons Tool box, i f used i n conjuncti on wi th Si mul i nk, i s par t of thi s
envi ronment many bl ocks are actual l y masked Si mul i nk model s.
The Using Simulink gui de descr i bes how to work wi th Si mul i nk. I t expl ai ns
how to mani pul ate Si mul i nk bl ocks, access bl ock par ameters, and connect
bl ocks to bui l d model s. I t al so provi des r efer ence descr i pti ons of each bl ock i n
the standar d Si mul i nk l i br ar i es.
Note: The Communi cati ons Tool box r equi r es ver si on 1.3c or l ater of Si mul i nk
i f you want to run the tool box i n the Si mul i nk envi r onment.
Recommended Pr oducts
The Communi cati ons Tool box takes ful l advantage of the functi onal i ty and
structure of Si mul i nk. Al though the Communi cati ons Tool box does not requi re
Si mul i nk to run, usi ng Si mul i nk wi th the tool box i s hi ghl y r ecommended for
system si mul ati on.
Ther e ar e other opti onal MathWor ks pr oducts that you can use wi th the
Communi cati ons Tool box. Whi l e the Communi cati ons Tool box provi des some
suppor t for channel noi se gener ator s, you can fi nd a br oader sel ecti on of noi se
generator s i n the Stati sti cs Tool box. The Real -Ti me Wor kshop
TM
i s an opti onal
software component that you can use to generate code from Si mul i nk model s.
The DSP Bl ockset i s a col l ecti on of bl ock l i br ari es desi gned for use wi th
Si mul i nk. These bl ock l i br ar i es are desi gned speci fi cal l y for di gi tal si gnal
pr ocessi ng appl i cati ons, such as convol uti on and Fouri er transfor ms. Al l these
pr oducts ar e compati bl e wi th the Communi cati ons Tool box.
1-5
Installation
The Communi cati ons Tool box fol l ows the same i nstal l ati on procedures as the
MATLAB tool boxes.
To i nstal l thi s tool box on a wor kstati on, see the I nstallation Guide for UNI X.
To i nstal l the tool box on a PC or Maci ntosh, refer to the I nstallation Guide
for PC and Macintosh.
To determi ne i f the Communi cati ons Tool box i s al ready i nstal l ed on your
system, check for subdi r ectori es named comm, comms i m, and commf un under the
comm subdi rector y wi thi n the mai n tool box di r ector y or fol der .
Using the Toolbox
If you are new to the communications field, r ead through the rest of thi s chapter,
the I ntroduction to Communication Systems chapter , and the Tutorial chapter .
These two chapters provi de the necessar y i nfor mati on for you to under stand
the key techni ques i n the communi cati ons fi el d.
If you are an experienced communications user, you need to r ead through the rest
of thi s secti on. You may want to ski p the I ntroduction to Communication
Systems chapter . You can refer back to the Tutorial and Examples chapters for
fur ther detai l s about any speci fi c topi c.
I f you just want to star t as soon as possi bl e, r ead through the r est of thi s
secti on. You may al so want to read thr ough the Di fferences between Si mul i nk
and MATLAB Si mul ati on secti on i n Chapter 2.
Al l tool box user s can l ear n to use the tool box by usi ng the exampl es provi ded
i n the Si mul i nk bl ock l i br ary. Type
c omml i b
i n the MATLAB workspace.
Doubl e-cl i cki ng any bl ock i n the commu wi ndow bri ngs up a functi on bl ock
subl i br ary or a more detai l ed categor y subl i brar y. Except for sel f-expl anatory
uti l i ty functi ons, every functi on bl ock i n thi s tool box has a compani on exampl e
that shows how to use the bl ock. Al l functi on bl ocks ar e bl ack wi th a whi te
background. Al l exampl e bl ocks are bl ack wi th a cyan backgr ound. By
doubl e-cl i cki ng a Si mul i nk bl ock di agr am, you can begi n i ts si mul ati on by
choosi ng Start i n the Simulation menu.
1 Before You Begin
1-6
The Communi cati ons Tool box suppor ts an onl i ne i nteracti ve exampl e that you
can access by typi ng
c ommgui
i n the MATLAB wor kspace. A descr i pti on of how to use thi s exampl e i s
pr ovi ded i n the MATLAB Functi ons secti on i n Chapter 2.
To vi ew al l MATLAB functi ons i n the tool box, type
hel p comm
for a l i st of al l tool box commands.
The Communi cati ons Tool box i s di vi ded i nto MATLAB functi ons and Si mul i nk
bl ock l i br ar i es. The subdi r ector y comm contai ns the MATLAB functi ons. The
subdi r ectory c omms i m contai ns the Si mul i nk bl ock l i br ary.
c omm MATLAB functi ons
c omms i m Si mul i nk bl ock l i brar y
I n addi ti on, there i s a comms f un subl i brar y, whi ch i ncl udes al l S-functi on fi l es.
I f you use the MATLAB functi ons, see the onl i ne MATLAB Functi on Refer ence
for i nfor mati on on speci fi c MATLAB functi ons. The functi on r efer ence
descri pti ons i ncl ude a synopsi s of the functi ons syntax, as wel l as a compl ete
expl anati on of opti ons and oper ati on.
I f you use the Si mul i nk bl ock l i brary, you shoul d r ead the Using Simulink
gui de for i nfor mati on on speci fi c functi on bl ocks. The bl ock r efer ence
descri pti ons i ncl ude the parameter setti ngs of the bl ocks as wel l as a compl ete
expl anati on of opti ons and oper ati on.
Organization of this Manual
Chapter 2 pr ovi des a bri ef overvi ew of communi cati on systems.
Chapter 3 pr ovi des a thor ough descri pti on of the var i ous communi cati on
techni ques i mpl emented i n the Communi cati ons Tool box. The di scussi on i s
based on i nter acti on wi th the functi ons and bl ocks pr ovi ded i n thi s tool box.
Thi s chapter does not di scuss theoreti cal i ssues. You can use thi s chapter to
scan qui ckl y through each ar ea i n the communi cati on systems fi el d. For your
conveni ence, Appendi x B, Bibliography, l i sts standar d r efer ence books i n the
communi cati ons fi el d.
1-7
Chapter 4 pr ovi des si mul ati on exampl es for communi cati on systems. Some
resul ts of the exampl es are shown usi ng fi gures cr eated by MATLAB Handl e
Gr aphi cs

. A number of the exampl es ar e based on practi cal communi cati on


systems.
Chapter 5 contai ns detai l ed descr i pti ons of al l MATLAB M-fi l e functi ons i n the
Communi cati ons Tool box. The chapter l i sts the functi ons al phabeti cal l y.
Chapter 6 contai ns the Si mul i nk bl ock l i brary. Each bl ock i n the Si mul i nk
bl ock l i brar y i s di scussed i n detai l . The Si mul i nk l i br ary i s di vi ded i nto several
subl i br ari es based on functi onal i ty. Refer to the begi nni ng of chapter 6 for a
di scussi on of that chapters or gani zati on.
Appendi x A di scusses usi ng the Real -Ti me Wor kshop wi th the
Communi cati ons Tool box, and Appendi x B contai ns a bi bl i ography.
Acknowledgments
The author woul d l i ke to acknowl edge the fol l owi ng peopl e:
Dar rel Judd, Har man Moti ve, revi ewed the software and documentati on, and
provi ded the earl y-l ate gate synchroni zati on exampl e i n Chapter 4.
Wal ter Chen, Texas I nstruments, provi ded the HDSL exampl e i n Chapter 4.
I rvi ne Reed, USC, pr ovi ded constructi ve comments and suggesti ons dur i ng the
earl y phase of devel opment.
Eri c Yang, AT&T, provi ded experti se i n the communi cati ons fi el d.
Ri char d Townsend, GTE, revi ewed the software and documentati on.
Bi l l Bal i nt hel ped wri te the documentati on. Donna Sul l i van and Peg Ther i aul t
edi ted the documentati on and provi ded pri nti ng support. The cover was
desi gned by Ken Hyman. Jun Wu conver ted the err or-control codi ng functi ons
to C for Real -Ti me Workshop compati bi l i ty. He al so conducted tests and
assi sted i n documentati on. Ken Kar nofsky and Yama Habi bzai or gani zed the
beta tests. Andy Gr ace r evi ewed the softwar e and the documentati on.
1 Before You Begin
1-8

2
I ntroducti on to
Communi cati on Systems
The Parts of a Communication System . . . . . . . . 2-3
The Communi cati ons Tool box Bl ock Li br ary . . . . . . . 2-4
MATLAB Functions . . . . . . . . . . . . . . . . . 2-8
Differences Between Simulink and
MATLAB Simulation . . . . . . . . . . . . . . 2-10
Data Fl ow Si mul ati on Exampl e . . . . . . . . . . . . . 2-10
Ti me Fl ow Si mul ati on Exampl e . . . . . . . . . . . . . 2-12
Compar i son of Ti me and Data Fl ow Si mul ati on Schemes . . 2-14
2 Introduction to C om m unication System s
2-2
Communi cati on i nvol ves the tr ansfer of i nfor mati on from one pl ace to
another . Communi cati on can take many forms; tal ki ng i s a common way for
peopl e to communi cate between each other . However, one persons voi ce i s not
l oud enough to be audi bl e over a l ong di stance. So peopl e must r el y on other
communi cati on systems to transfer i nfor mati on over l ong di stances. For
exampl e, Bostoni ans are used to getti ng weather i nfor mati on by l ooki ng at the
l i ghts on the top of the ol d John Hancock bui l di ng si nce peopl e i n the Boston
ar ea know the l i ghts mean:
Steady bl ue Cl ear vi ew
Fl ashi ng bl ue Cl ouds due
Steady r ed Rai n ahead
Fl ashi ng r ed Snow i nstead
(Fl ashi ng r ed i n the summer means that the Red Sox basebal l team i s pl ayi ng
i n town that ni ght.)
I n most cases, l i ght tr avel s l onger di stances than sound. Usi ng thi s pr i nci pl e,
engi neers devel oped vari ous ways to tr ansfer messages. One of the most
popul ar methods i s to use r adi o fr equency si gnal s to tr ansfer human voi ce
si gnal s over a l ong di stance. The process of usi ng a radi o frequency si gnal (a
hi gher fr equency si gnal ) to car ry a human voi ce (a l ower frequency si gnal ) i s
known as modulation. The recei ver uses a demodul ati on method to recover the
r ecei ved modul ated si gnal . There are di fferent methods for si gnal modul ati on/
demodul ati on. The demodul ati on method must match the modul ati on method
to recover the transmi tted si gnal cor rectl y.
Voi ce goes shor t di stances
Li ght travel s much l onger di stances
Huh....?
Got i t.
The Parts of a C om m unication System
2-3
The Parts of a Communication System
A si mpl e communi cati on system contai ns thr ee par ts: the tr ansmi tter , the
channel (the tr ansmi tti ng medi um), and the r ecei ver . The i nformati on sour ce
and i nfor mati on si nk ar e al so consi der ed part of the communi cati on system.
The task of communi cati on system engi neer s i s to desi gn and mai ntai n a
communi cati on system such that the r ecei ver s can corr ectl y demodul ate,
decode, and cor rect er rors i n the transmi tted message.
I n gener al , a communi cati on system can be cl assi fi ed as ei ther anal og or
di gi tal . A transmi tter for an anal og communi cati on system may i ncl ude si gnal
modul ati on and mul ti pl e access. Multiple access i s a shar i ng techni que
whereby si gnal s ar e sent i n tur n. A r ecei ver for an anal og communi cati on
system may i ncl ude a si gnal fi l ter i ng bank and si gnal demodul ati on.
The messages i n a di gi tal communi cati on system ar e r epresented by usi ng
di gi tal number s or bi ts.A tr ansmi tter for a di gi tal communi cati on system may
i ncl ude sour ce codi ng, data compr essi on, error -control codi ng, di gi tal
modul ati on, and mul ti pl e access. Source coding i s a process usi ng a di gi tal
si gnal to represent an anal og si gnal . Data compression i s a process that
converts the message i nto a compressed message, meani ng a message that has
fewer i nfor mati on bi ts than the ori gi nal message. The recei vi ng si de can
recover the ori gi nal message fr om the compr essed message by a data
decompressi on process. Error-control coding adds r edundant er ror -checki ng
and/or er ror-corr ecti on bi ts. The r ecei vi ng si de can use the extra bi ts to detect
and/or cor rect the tr ansmi ssi on er ror s. Digital modulation maps the di gi tal
si gnal to an anal og si gnal and then uses a hi gher frequency si gnal to carr y the
anal og si gnal . Thi s fi gur e shows the parts of the tr ansmi ssi on process:
Channel Transmi tter
Recei ver
I nformati on
Si nk
I nformati on
Sour ce
Channel
Demodul ati on
I nformati on
Si nk
I nformati on
Sour ce
Modul ati on
Mul ti pl e
access
Other si gnal
Other si gnal
Fi l ter
2 Introduction to C om m unication System s
2-4
A recei ver i s conceptual l y the i nverse of the tr ansmi tter. I n most cases, the
r ecei vi ng process method shoul d match exactl y the tr ansmi tti ng pr ocess
method to r ecover the transmi tted message. Thi s fi gur e shows the par ts of the
r ecei vi ng process:.
The channel s i n communi cati on systems may vary i n di fferent appl i cati ons. I n
general , a channel may i ntroduce noi se, fadi ng, phase shi fti ng, and
i nterference to the tr ansmi tted si gnal .
The techni ques used i n the di gi tal communi cati ons fi el d are al so used i n other
appl i cati ons. For i nstance, source codi ng, data compr essi on, and er ror -contr ol
codi ng techni ques are wi del y used i n computer stor age appl i cati ons.
Except for data compressi on, thi s tool box provi des r eady-to-use tool s to desi gn,
anal yze, and si mul ate communi cati on systems. These systems i ncl ude both
anal og and di gi tal communi cati on systems.
The Communications Toolbox Block Library
To use the bl ock l i brar y i n the Communi cati ons Tool box, you must have
Si mul i nk i nstal l ed. To open the bl ock di agr am of the Si mul i nk bl ock l i br ary,
type the command
c omml i b
i n the MATLAB wor kspace.
Channel
I nfor mati on
Source
Source
codi ng
Data
compressi on
Err or-contr ol
codi ng
Modul ati on
Mul ti pl e
access
Other si gnal
Channel
I nfor mati on
Si nk
Sour ce
decodi ng
Data
compr essi on
Err or-contr ol
decodi ng
Demodul ati on Fi l ter
The Parts of a C om m unication System
2-5
The bl ock di agram of the top l evel of the Si mul i nk l i br ary shows the
communi cati on system str uctur e:
Figure 2-1: The Communications Toolbox Simulink Block Library
The upper row of bl ocks i s the transmi tti ng par t of a communi cati on system.
The bottom r ow contai ns the r ecei vi ng part of a communi cati on system. The
recei vi ng part i s a mi rr or i mage of the transmi tti ng par t. I n most but not al l
cases, the r ecei vi ng computati on i s exactl y the r everse of the tr ansmi tti ng
computati on. Bel ow the communi cati on system di agram ar e uti l i ti es and
synchroni zati on subl i br ar i es that pl ay suppor ti ng rol es i n the
tr ansmi tter-channel -recei ver sequence.
Doubl e-cl i cki ng any bl ock i n thi s l i br ar y opens a subl i br ar y. The same bl ock
l i br ary opens whenever you doubl e-cl i ck a tr ansmi tti ng bl ock or i ts
mi r ror-i mage r ecei vi ng bl ock. For exampl e, doubl e-cl i cki ng the Err or control
codi ng or Err or contr ol decodi ng bl ocks opens up the same subl i brary.
Two subl i brar i es contai n fur ther subcategori es. These are:
Err or -control code/decode
Modul ati on/demodul ati on
Doubl e-cl i ck any subcategor y bl ock to r each the functi on bl ocks.
2 Introduction to C om m unication System s
2-6
A subl i br ary usual l y contai ns two di fferent bl ock types: functi on bl ocks and
demo bl ocks. The demo bl ocks ar e cyan col or ed (or gr ay on bl ack and whi te
screens). You can use the functi on bl ocks to bui l d the bl ock di agr am of your own
communi cati on system. Doubl e-cl i cki ng a functi on bl ock opens the parameter
di al og box to set the par ameters for that bl ock. I n some subl i br ar i es, ther e ar e
l i nes to l i nk the tr ansmi tti ng bl ocks and recei vi ng bl ocks, whi ch means that
they are di rect pai rs of the tr ansmi tti ng and the r ecei vi ng process. I n gener al ,
the bl ocks must be used together i n a communi cati on system. Doubl e-cl i cki ng
a demo bl ock opens a bl ock di agram of a si mpl e system whi ch i l l ustr ates the
use of bl ocks l ocated on the l eft of the demo bl ock i n the subl i br ary.
The fi gur e on the next page shows an exampl e of the hi erar chi cal str uctur e of
the Communi cati ons Tool box Si mul i nk Bl ock Li brar y. Doubl e-cl i cki ng a bl ock
opens a bl ock di agr am i n the next l evel .
The Parts of a C om m unication System
2-7
Figure 2-2: The Hierarchical Structure of the Communications Toolbox
Simulink Block Library
. Illustrative blocks
. Demonstration blocks
. Avalaible blocks
Tutorial
Sink
Source
COMMUNICATIONS TOOLBOX SIMULINK BLOCK LIBRARY
? Demos
Utilities
/misc
Synchronization
Error
control
coding
Source
decoding
Source
coding
Error
control
decoding
Modulation
From other
source
To other
sink
Demodulation
Multiple
access
Multiple
access
Transmitter
/filters
Receiver
/filters
C
h
a
n
n
e
l
(passband simulation)
MASK
MASK mod
MASK
MASK demod
Digital Modulation/Demodulation Library
SQASK
demo2
MFSK
demo
MPSK
MPSK mod
AQASK
Arbitrarymap
QASK demod
SQASK
Squaremap
QASK mod
SQASK
Squaremap
QASK demod
CQASK
Circlemap
QASK mod
CQASK
Circlemap
QASK demod
SQASK
demo
MASK
demo
CQASK
demo
AQASK
demo
MPSK
demo
. Demonstration blocks
AQASK
Arbitrarymap
QASK mod
Cohe MFSK
Coherence
MFSK demod
Nonc MFSK
Noncoherence
MFSK demod
MPSK
MPSK demod
MFSK
MFSK mod
Rd wksp CQASK CQASK
Error
meter
View
constellation
Demonstr ati on bl ock di agram
Functi on subl i brar y
baseband passband
Modulation/Demodulation Library
Digital
mo/dem
cmplx env
Digital
mo/dem
Digital Mo/Dem:
Analog
mo/dem
Analog
mo/dem
cmplx env
Analog Mo/Dem:
Digital
mo/demce
map/demap
Digital
mo/dem
map/demap
Separated Version for Digital Mo/Dem:
Digital Modulation = map+modulation
Digital Demodulation = demodulation+demap
Note:
Top l evel l i brar y bl ock di agram
Mi ddl e l evel subl i brar y
2 Introduction to C om m unication System s
2-8
MATLAB Functions
The Communi cati on Tool box i ncl udes the most commonl y used functi ons for
communi cati on system desi gn, anal ysi s, and si mul ati on. The MATLAB
functi ons are i n subdi rectory c omm. You can get a l i st of the contents by typi ng
hel p comm
or
ht hel p c ommhel p
Often there ar e var i ous ways to i mpl ement a gi ven concept i n thi s tool box. For
i nstance, ther e ar e si x di fferent anal og modul ati on techni ques supported i n the
Communi cati ons Tool box. You can fi nd gener al i nformati on for usi ng the
anal og modul ati on functi on by typi ng
hel p amod
on the command l i ne. The hel p uti l i ty l i sts a set of method stri ngs that
descri be each of the modul ati on techni ques. For hel p on how to use a speci fi c
modul ati on method, type amod fol l owed by the method str i ng. For i nstance, to
fi nd out about the QAM method, type:
amod qam
M A TLA B Functions
2-9
Note that thi s command produces the hel p fi l e for the QAM method even
though the wor d hel p doesnt appear on the command l i ne. Thi s tabl e l i sts al l
the functi ons that use thi s parti cul ar hel p command:
Function Description
amod Passband anal og modul ati on. Methods of choi ce: amdsb-sc,
amdsb-sc, amssb, qam, fm, pm.
ade mod Passband anal og demodul ati on.
amodc e Baseband anal og modul ati on. Methods of choi ce: amdsb-sc,
amdsb-sc, amssb, qam, fm, pm.
ade modc e Baseband anal og demodul ati on.
dmod Passband di gi tal modul ati on. Methods of choi ce: ask, psk,
qask, fsk, msk.
dde mod Passband di gi tal demodul ati on.
dmodc e Baseband di gi tal modul ati on. Methods of choi ce: ask, psk,
qask, fsk, msk.
dde modc e Baseband di gi tal demodul ati on.
modmap Di gi tal si gnal to anal og si gnal mappi ng. Methods of choi ce:
ask, psk, qask, fsk, msk.
demodmap Anal og si gnal to di gi tal si gnal mappi ng.
e nc ode Er ror-control encodi ng. Methods of choi ce: hammi ng, bl ock,
cycl i c, bch, r s, convol uti on.
dec ode Er ror-control decodi ng.
2 Introduction to C om m unication System s
2-10
Differences Between Simulink and MATLAB Simulation
Ther e ar e di fferences between si mul ati on wi th Si mul i nk bl ock di agr ams and
MATLAB functi ons. I n Si mul i nk si mul ati on, each bl ock i n the di agram
advances at each ti me step. I n other wor ds, al l the Si mul i nk bl ocks ar e
perfor med concurr entl y dur i ng each ti me step; thi s i s cal l ed ti me fl ow
si mul ati on. I n MATLAB si mul ati on, the functi ons sequenti al l y fol l ow the data
fl ow. Thi s means that the processed data goes thr ough one computati on stage
before acti vati ng the next stage. Thi s i s known as data fl ow si mul ati on. Speci fi c
appl i cati ons may requi re one scheme over the other.
Data Flow Simulation Example
Lets use an exampl e to expl ai n the data fl ow si mul ati on concept. The exampl e
shows a 16-QASK modul ati on wi th BCH er ror-contr ol codi ng. The si mul ati on
uses the MATLAB functi ons enc ode and de code for er ror -contr ol codi ng and
decodi ng. I t uses the MATLAB functi ons dmod and ddemod for di gi tal
modul ati on and demodul ati on. The message sour ce used i n the si mul ati on i s a
sequence of r andom i ntegers. I n the command l i nes, the l i nes starti ng wi th ' %'
ar e comment l i nes:
% Def i ne t he mul t i pl e numbe r , code wor d l e ngt h, and mes s age
% l engt h.
M = 16; N = 15; K = 11;
% Def i ne t he c ar r i e r f r eque nc y , di gi t al t r ans f e r f r e quency ,
% and s i mul at i on f r eque nc y.
Fc = 10000; Fd = 1000; Fs = 100000;
% Gener at e a 1100- by- 1 mat r i x t hat c ont ai ns t he di gi t al me s s age
% t o be t r ans f er r e d. The mul t i pl e number i s M.
% r andi nt ge ne r at e s r andom i nt .
ms g = r andi nt ( K100, 1) ;
% Us e BCH code . The c odewor d l engt h i s N
% and t he me s s age l engt h i s K.
c ode = e nc ode( ms g, N, K, ' bc h' ) ;
D ifferences Betw een Sim ulink and M A TLA B Sim ulation
2-11
% Us e a 16- QASK di gi t al modul at i on met hod.
% The mul t i pl e numbe r i s M=16.
modu = dmod( code , Fc, Fd, Fs , ' qas k' , M) ;
% As s ume t he STD of t he added Gaus s i an noi s e i s 0. 1.
s t d_v al ue = 0. 1;
% Add AWGN wi t h STD equal t o s t d_val ue .
modu_noi s e = modu+r andn( l engt h( modu) , 1) s t d_v al ue ;
% Demodul at i on pr oce s s
demo = ddemod( modu_noi s e, Fc , Fd, Fs , ' qas k' , M) ;
% BCH dec ode
% The c odewor d l engt h i s N and t he mes s age l engt h i s K.
ms g_r = dec ode ( demo, N, K, ' bc h' ) ;
r at e = bi t e r r ( ms g, ms g_r , M)
I n the si mul ati on, the enti r e data vector i s processed as a uni t. The
computati on process gener ates a 1100-by-1 r andom i nteger vector . The
message si gnal i s encoded by BCH encodi ng functi ons. The encoded si gnal i s
sent to the next pr ocedur e, the QASK modul ati on, and so on. The modul ati on
process does not begi n unti l the er ror contr ol encode i s fi ni shed. The data
process of the above MATLAB commands fol l ows the ar rows i ndi cated i n thi s
bl ock di agr am:
Once the si mul ati on fi ni shes, you can use MATLAB to post-process the data.
The l ast l i ne of the above MATLAB commands compares the ori gi nal data wi th
the recovered data fr om the r ecei vi ng si de. I n general , when usi ng data fl ow
si mul ati on, you have to wai t unti l the end of the si mul ati on to see the overal l
resul ts and to compar e the r esul ts to previ ous runs. I t i s not possi bl e to reset
parameter s i n the mi ddl e of a si mul ati on. I f you want to change a par ameter
i n the MATLAB code, you must r erun the si mul ati on after maki ng the change.
Sour ce
si gnal
BCH
encodi ng
QASK
mod
AWGN
channel
QASK
demod
BCH
decodi ng
Recover
si gnal
2 Introduction to C om m unication System s
2-12
Time Flow Simulation Example
Usi ng the Si mul i nk bl ock l i brar y, you can bui l d a Si mul i nk bl ock di agram that
cl osel y fol l ows the par ts of the communi cati ons process descri bed ear l i er i n thi s
chapter . Thi s fi gure shows a Si mul i nk bl ock di agr am that perfor ms the same
functi ons as the Data Fl ow Si mul ati on Exampl e:
The l ong sequence of bl ocks i n the center r ow of the fi gure are the functi on
bl ocks. The Vector to scal ar converter , Vector pul se, and Edge detector bl ocks
ar e I /O and ti mi ng bl ocks that suppor t the basi c communi cati ons functi ons i n
the fi gure. Li ke the bl ock di agram i ntroduced i n the Data Fl ow Si mul ati on
Exampl e, thi s bl ock di agram i ntroduces the Si gnal gener ator (Sampl ed read
vari abl e bl ock), BCH encode, QASK modul ati on, Channel , QASK
demodul ati on, and BCH decode bl ocks. The Er ror Rate Meter bl ock compar es
the ori gi nal message to the r ecover ed si gnal on the recei vi ng si de. I t
cor responds to the l ast l i ne of the MATLAB code i n the Data Fl ow Si mul ati on
Exampl e.
Rd wksp
Vec to sca
converter
BCH en
Vec to sca
converter
SQASK AWGN SQASK
Sca to vec
converter
BCH de
Vec to sca
converter
Error Rate
Meter
Edge det. Pulse
D ifferences Betw een Sim ulink and M A TLA B Sim ulation
2-13
Unl i ke the MATLAB si mul ati on, Si mul i nk recovers and di spl ays the recei ved
message bi ts at each si mul ati on ti me step. Thi s fi gur e shows the err or rate
compar i son map gener ated by the Er ror Rate Meter bl ock:
Message
symbol s
Recover ed
symbol s
Symbol
Bi t er ror
er ror
2 Introduction to C om m unication System s
2-14
I n the si mul ati on the ti mi ng for the demappi ng can be chosen by tuni ng the
pul se generator . The process for determi ni ng the opti mal demappi ng rate
i nvol ves usi ng an eye-pattern plot, whi ch i s a mul ti pl e overl ai d tr ace pl ot of the
r ecei ved si gnal . The deci si on i s deter mi ned by fi ndi ng wher e the eye i s most
wi del y open:
The deci si on poi nt i n thi s eye-patter n pl ot i s at t=0.005. Thi s means that the
tr i gger si gnal for the QASK demodul ati on bl ock shoul d be set to 1/0.005 = 200
Hertz.
The Si mul i nk si mul ati on i s an i nteracti ve si mul ati on. Thi s means that you can
r eset most of the parameter s i n a bl ock duri ng the si mul ati on (not al l
par ameters can be r eset dur i ng the si mul ati on). You can use the di spl ay bl ocks
to show the si mul ati on resul ts whi l e the si mul ati on i s sti l l r unni ng. You can
al so save the data i nto fi l es or i nto MATLAB wor kspace var i abl es and do post-
pr ocessi ng on the saved data usi ng MATLAB functi ons.
Comparison of Time and Data Flow Simulation
Schemes
Data fl ow and ti me fl ow si mul ati ons resul t i n the same sol uti ons (wi thi n
computati onal tol erances). Si nce data and ti me fl ow si mul ati on schemes
handl e si mul ati on ti me di ffer entl y, one method may be mor e sui tabl e than the
other i n a gi ven appl i cati on. I n the exampl es descr i bed i n the l ast two
0 0.001 0.002 0.003 0.004 0.005 0.006 0.007 0.008 0.009 0.01
0.5
0
0.5
1
1.5
2
2.5
3
3.5
time (second)
a
m
p
l
i
t
u
d
e
EyePattern Diagram
D ifferences Betw een Sim ulink and M A TLA B Sim ulation
2-15
subsecti ons, the data fl ow and ti me fl ow computati ons can be vi ewed as
processes wi th di fferent ti mi ng. Thi s fi gure i s a qual i tati ve compar i son of the
ti mi ng used i n the two schemes:
Figure 2-3: Comparison of Time and Data Flow Simulations
The arr ows i nsi de the process categor y bl ocks i ndi cate the si mul ati on del ay i n
the process. I f the ar row i s str i ctl y verti cal , there i s no del ay i n the pr ocess. I f
the ar row i s not str i ctl y verti cal , ther e i s a del ay i n the process. Because of
cumul ati ve del ays, the data sent at ti me t from the data sour ce i s ful l y
recovered at ti me t+Dt, where t i s the transmission delay. The transmi ssi on
del ay can be model ed i n both data fl ow and ti me fl ow si mul ati on. Usi ng the
Si mul i nk user i nterface i n the ti me fl ow si mul ati on, you can adjust the
esti mated ti me del ay i n the communi cati on system by changi ng the offset of
the tr i gger pul se si gnal s. The ti me del ay i s an i mpor tant factor i n the desi gn of
a communi cati on system as wel l as i n the communi cati on si mul ati on. Fr om the
synchroni zati on poi nt of vi ew, the ti me fl ow si mul ati on i s mor e favor ed than
the data fl ow si mul ati on.
I n data fl ow si mul ati on, you can easi l y desi gn a fi l ter i n the domai n or perform
a spectr um anal ysi s at any stage i n the si mul ati on. For i nstance, you can
i mpl ement a per fect cut-off frequency fi l ter. The i mpl ementati on of a per fect
cut-off frequency fi l ter i s al most i mpossi bl e when wor ki ng i n the ti me domai n.
Si nce a data fl ow si mul ati on uses batch fi l e pr ocessi ng, you can per for m a
spectral anal ysi s on the enti r e data set and shape the data by usi ng the desi red
fi l ters. Thi s i s useful for theoreti cal resear ch. I n a pr acti cal communi cati on
system, the si gnal s are pr ocessed i n real ti me. To use a speci al fi l ter , you can
ei ther i mpl ement the r equi r ed fi l ter as a ti me domai n fi l ter , or hol d the
Si mul ati on ti me fl ow
S
i
m
u
l
a
t
i
o
n

d
a
t
a

f
l
o
w
Source si gnal generator
Er ror-control encodi ng
Di gi tal modul ati on
Transmi tti ng channel
Di gi tal demodul ati on
Er ror-control decodi ng
Er ror-rate anal ysi s
t t+Dt
2 Introduction to C om m unication System s
2-16
tr ansfer data i n a buffer , pr ocessi ng the buffered data usi ng frequency
anal ysi s. Thi s fi gur e i l l ustr ates the buffer i ng-data pr ocedur e:
Figure 2-4: Data Buffering
Frequency fi l ter i ng can be done at the vector process stage i n the fi gure. Note
that the buffer process i ntr oduces a l onger ti me del ay compared to the ti me
domai n fi l ter . I t al so i ntr oduces mor e computati onal compl exi ty. The l onger
the buffer l ength, the more accurate the pr ocess, but the cost i s a l onger del ay.
I n the extreme case, when the buffer si ze i s the same as the enti r e data vector
si ze, the ti me fl ow si mul ati on i s equi val ent to the data fl ow si mul ati on. I n thi s
case, Dt equal s the enti re l ength of the process.
Sequenti al i n Buffer
Vector Pr ocess
Buffer Sequenti al out

3
Tutori al
Signal Generators and Display Devices . . . . . . . . 3-5
Source Coding . . . . . . . . . . . . . . . . . . . 3-13
Error-Control Coding . . . . . . . . . . . . . . . . 3-23
Signal Multiple Access . . . . . . . . . . . . . . 3-104
Transmitting and Receiving Filters. . . . . . . . . 3-113
Channels. . . . . . . . . . . . . . . . . . . . . 3-120
Synchronization . . . . . . . . . . . . . . . . . 3-123
Utilities . . . . . . . . . . . . . . . . . . . . . 3-126
Galois Field Calculations . . . . . . . . . . . . . 3-130
3 Tutorial
3-2
Thi s chapter pr ovi des an i ntroducti on to the techni ques i mpl emented i n the
Communi cati ons Tool box. Thi s chapter al so r evi ews communi cati on systems
concepts. I t does not contai n theoreti cal di scussi ons. See Appendi x B at the end
of thi s Users Guide for references to mor e detai l ed di scussi ons of
communi cati ons theory. I f you ar e a begi nner i n the communi cati on fi el d, you
can l earn communi cati ons techni ques whi l e usi ng the tool box. I f you are an
exper t, you can modi fy the functi ons and the bl ocks for your own appl i cati ons.
Thi s chapter assumes that you know basi c communi cati ons termi nol ogy, such
as the di sti ncti on between bi ts and symbol s. I f you dont know these
di sti ncti ons, r efer to a general reference i n communi cati ons theory, such as Lee
& Messer schmi dt or Pr oaki s.
Thi s chapter exami nes communi cati on techni ques usi ng the M-fi l es and
Si mul i nk bl ocks provi ded i n the tool box. For descri pti ons of i ndi vi dual
Si mul i nk bl ocks and MATLAB functi ons, r ead Chapter 5, MATLAB Function
Reference, and Chapter 6, Simulink Block Library Reference.
A typi cal communi cati on system i ncl udes a si gnal source, si nk, and channel as
wel l as processes for tr ansmi tti ng and r ecei vi ng. Except for the channel , these
concepts di vi de i nto pai rs. The secti ons i n thi s chapter fol l ow the transmi tti ng/
r ecei vi ng di agr am fl ow as shown i n the fi gur e:
I nfor mati on
Sour ce
Sour ce
codi ng
Er ror -contr ol
codi ng
Modul ati on
Mul ti pl e
access
Other si gnal
I nfor mati on
Si nk
Sour ce
decodi ng
Er ror -contr ol
decodi ng
Demodul ati on
C
h
a
n
n
e
l
Mul ti pl e
access
Tr ansmi tter
/fi l ter s
Recei ver
/fi l ter s
3-3
Thi s tool box contai ns a Si mul i nk bl ock subl i br ary and a MATLAB functi on
category for each i tem i n the fi gur e. I n addi ti on, the tool box al so contai ns
var i ous synchr oni zati on and uti l i ti es functi ons and bl ocks. The tabl e bel ow
l i sts the basi c pr ocesses i nvol ved i n communi cati ons and the functi ons
associ ated wi th each process. The MATLAB functi ons ar e l i sted i n
parentheses. Each of these processes i s di scussed i n thi s chapter:
Process Associated Functions
Si gnal Generator and Di spl ay
Devi ces
Random si gnal generator
Di spl ay devi ces (e ye s c at )
Er ror-r ate anal ysi s (s y me r r /bi t t er )
Source Codi ng Scal ar quanti zati on (quant i z e /l l oyd)
A-l aw compander (compande r )
-l aw compander (compande r )
Pr edi cti ve quanti zati on
(dpc me nco/dpc mdec o/dpc mopt )
Er ror-Contr ol Codi ng Li near bl ock code
Hammi ng code
(e nc ode /dec ode for al l codi ng methods)
Cycl i c code
BCH code
Reed-Sol omon code
Convol uti onal code
Modul ati on and Demodul ati on Passband anal og (amod/ademod)
Baseband anal og (amodce /ade modce )
Passband di gi tal (dmod/ddemod)
Baseband di gi tal (dmodce /dde modc e )
3 Tutorial
3-4
Process Associated Functions
Si gnal Mul ti pl ex and
Demul ti pl ex (Mul ti pl e Access)
Ti me di vi si on
Frequency di vi si on
Code di vi si on
Tr ansmi tti ng and Recei vi ng
Fi l ter s
Rai sed cosi ne fi l ter
Hi l ber t transfor m fi l ter
Compl ex par ameter fi l ter
Channel s Addi ti ve whi te Gaussi an noi se
Rayl ei gh fadi ng channel
Rayl ei gh noi se channel
Uti l i ti es/
Mi scel l aneous
Synchr oni zati on phase-l ocked l oop
Format conver si on
Vol tage-control l ed osci l l ator
Gal oi s fi el d computati ons (MATLAB
functi ons onl y)
Signal G enerators and D isplay D evices
3-5
Signal Generators and Display Devices
Thi s tool box i ncl udes a number of si gnal generator and si gnal di spl ay bl ocks
and functi ons. The Source subl i br ary contai ns the si gnal generator and si gnal
di spl ay bl ocks. The si gnal gener ators i ntroduced i n thi s secti on, al l of whi ch
gener ate random si gnal s, ar e used i n the tr ansmi tti ng channel . The di spl ay
devi ces i ntr oduced, i ncl udi ng eye-patter n di agr ams and scatter pl ots, are
among the most commonl y used techni ques i n err or anal ysi s of communi cati on
systems.
Random Signal Generators
Thi s tool box provi des Gaussi an, Rayl ei gh, Ri ci an, Poi sson, and uni for m noi se
gener ators i n the Si mul i nk bl ock l i brar y.
You can fi nd the MATLAB functi ons for generati ng the r andom vari abl es i n the
Stati sti cs Tool box.
Ga ussi a n N oise Gener a tor
Gaussi an noi se i s the most wi del y used noi se model i n communi cati on system
anal ysi s. The probabi l i ty densi ty functi on (pdf) of the n-di mensi onal Gaussi an
noi se i s
where x i s a l ength n vector , K i s the n-by-n covari ance matri x associ ated wi th
x, and i s the mean val ue vector of x. Gaussi an noi se i s used i n the most
popul ar channel model i n communi cati on systems, the AWGN (addi ti ve whi te
Gaussi an noi se) channel .
You can fi nd the Gaussi an Noi se Generator bl ock i n the Sour ce subl i br ary and
the AWGN bl ock i n the Channel subl i br ary. r andn, whi ch generates nor mal l y
di str i buted numbers, i s avai l abl e as a bui l t-i n MATLAB functi on.
f x ( )
1
2 ( )
n
2
---
det K ( )
--------------------------------------
1
2
--- x ( )
T
K
1
x ( )
,
_
exp =
3 Tutorial
3-6
Ra yleigh N oi se Genera tor
The Rayl ei gh Noi se Generator bl ock generates si gnal s that ar e Rayl ei gh
di stri buted. Rayl ei gh noi se i s noi se wi th Rayl ei gh di str i buted ampl i tude. A
Rayl ei gh di stri buti on i s equi val ent to that of the root sum squar e (RSS) of a
two-di mensi onal , zero mean Gaussi an vari abl e. Let y
1
and y
2
be the two
i ndependent Gaussi an r andom var i abl es wi th zero mean and a common
vari ance
2
. The Rayl ei gh r andom var i abl e x i s . The pdf of the
Rayl ei gh noi se i s:
The mean val ue of thi s di stri buti on i s and i ts vari ance i s (2-/2)
2
. The
Rayl ei gh noi se i s fr equentl y used i n radi o channel s, such as cel l ul ar radi o
channel s.
Rici a n N oise Gener a tor
The Ri ci an Noi se Generator bl ock generates si gnal s that fol l ow a Ri ci an
di stri buti on. Let y
1
and y
2
be two i ndependent Gaussi an random vari abl es
wi th means m
1
and m
2
and a common vari ance
2
. The quanti ty v2, cal l ed the
noncentrality parameter, equal s m
1
2
+m
2
2
. The pdf of the Ri ci an noi se i s:
where functi on I 0(u) i s the modi fi ed zeroth or der Bessel functi on of the fi r st
ki nd gi ven by:
The mean val ue of Ri ci an noi se i s (2+m) and the vari ance i s 4(1+2m).
x y
1
2
y
2
2
+ =
f x ( )
x

2
------
x
2
2
2
---------
,

_
exp =
2
f x ( )
x

2
------ I
0
xv

2
------
,
_
e
x
2
v
2
+
2
2
--------------------
x 0
0 x 0 <

'

=
I
0
u ( )
1
2
------ e
u t cos
t d

=
Signal G enerators and D isplay D evices
3-7
Poisson Ra ndom I nteger Gener a tor
The Poi sson Random I nteger Generator bl ock gener ates i ntegers that fol l ow a
Poi sson di stri buti on. Thi s tool box uses the Poi sson r andom i nteger generator
for er ror -control code testi ng. The pdf of the Poi son di str i buti on i s:
The mean and var i ance of thi s di stri buti on ar e both equal to . When i s l ess
than 1, the probabi l i ty of the nonzer o data gener ated by the Poi sson random
number gener ator i s appr oxi matel y equal to . The bi nary er ror channel i n thi s
tool box uses thi s property to gener ate bi nary noi se si gnal s. You can fi nd the
Poi sson Random I nteger Gener ator bl ock i n the Sour ce subl i br ary.
Unifor m N oi se Genera tor
The Uni form Noi se Generator bl ock, whi ch generates uni for ml y di str i buted
noi se si gnal s, i s commonl y used i n the esti mati on of sour ce codi ng di storti on.
For b
up
> b
low
, the uni for ml y di str i buted r andom var i abl e x sati sfyi ng the
di str i buti on i s:
The mean val ue of thi s di str i buti on i s (1/2)*(b
up
+b
l ow
) and the var i ance i s
(1/12)*(b
up
+b
l ow
)
2
. You can fi nd the Uni form Noi se Gener ator bl ock i n the
Sour ce subl i br ary r and, whi ch gener ates uni forml y di stri buted number s, i s
avai l abl e as a bui l t-i n MATLAB functi on.
Display Devices
The Communi cati ons Tool box provi des di spl ay devi ces that make i t easi er to
anal yze the per formance of a communi cati on system. I ncl uded i n di spl ay
devi ces are the eye-patter n di agram, scatter pl ot, and er ror-r ate computati on.
Thi s tool box suppor ts both Si mul i nk bl ocks and MATLAB functi ons that
produce these di spl ay devi ces.
f x ( )

x
x!
-----e

when x=0,1,2,...
0 otherwi se

'

=
f x ( )
1
b
up
b
l ow

------------------------- when b
l ow
x b
up

0 other wi se

'

=
3 Tutorial
3-8
Eye- Pa tter n Dia gr a ms
I n communi cati ons, i t i s often useful to quanti fy the degr adati on of a
tr ansmi ssi on si gnal . Eye-pattern di agr ams, so-cal l ed because they are eye-l i ke
i n appear ance, are a wi del y used gr aphi cal i l l ustrati on of thi s degradati on. A
common way to generate eye-patter n di agr ams i s to set an osci l l oscope to
sweep a si gnal at the rate of 1/T, wher e T i s the symbol peri od. The conti nuous
over l ay of sweeps pr oduces the eye-patter n pl ot.
Di gi tal tr ansmi ssi on si mul ati on i nvol ves two di ffer ent sampl i ng frequenci es:
the deci si on fr equency, F
d
, at whi ch symbol val ue deci si ons ar e made, and the
si mul ati on sampl e fr equency, F
s
, wher e F
s
> F
d
. Let x be the si gnal at the
demodul ator output. I t i s sampl ed once duri ng each symbol per i od, and the
val ue of that sampl e i s used to determi ne whi ch symbol was most l i kel y
tr ansmi tted. Ther e ar e F
s
/F
d
data poi nts i n the 1/F
d
symbol per i od. The one
whi ch i s used to make the deci si on r egardi ng the esti mated val ue of the
tr ansmi tted symbol i s cal l ed the decision point. Note that i n thi s tool box the
symbol deci si on i s cal l ed demapping.
I n message transmi ssi on, a number of factor s may di stor t the recei ved si gnal ,
such as the tr ansmi tti ng/recei vi ng fi l ters, channel noi se, channel i nterference,
and the fi l ter s used i n the demodul ati on. A communi cati ons engi neer must
devel op an al gori thm for deci di ng what message was actual l y sent. You can use
an eye-patter n di agram to deter mi ne the deci si on poi nt, whi ch makes i t
possi bl e to deci de what message was most l i kel y sent. Usual l y, the deci si on
poi nt i s the poi nt where the eye i s most wi del y opened. Thi s i s the poi nt at
whi ch the si gnal i s l east sensi ti ve to phase var i ati ons and ti mi ng ji tter.
Thi s tool box provi des the Eye-Pattern Di agram bl ock i n the Si mul i nk l i brar y.
Ther e i s al so a MATLAB functi on ey es c at for pl otti ng eye-pattern di agrams.
You can al so use the di gi tal demodul ati on functi ons, such as dmod, dmodc e, and
demodmap, to pl ot eye-patter n di agr ams.
Eye-pattern di agrams ar e al so useful i n eval uati ng the effect of i nter symbol
i nterference (I SI ).
Signal G enerators and D isplay D evices
3-9
Eye- Pa ttern Dia gra m Ex a mple . Thi s exampl e demonstrates the use of the
eye-patter n pl ot i n the di gi tal demodul ati on for di gi tal transmi ssi on. Gi ven
that the M-ary number (the number of di fferent symbol s than can be
tr ansmi tted) of the si gnal source i s 16 and that the di gi tal modul ati on method
i s QASK, these command l i nes demonstrate the use of the eye-patter n pl ot:
% Def i ne t he M- ar y number , cal c ul at i on s ampl e f r e quency .
M = 16; Fs = 10;
% Def i ne t he numbe r of poi nt s i n t he c al cul at i on.
Pd = 100;
% The def aul t s y mbol r at e i s Fd = 1.
% Gener at e an i nt e ge r mes s age i n r ange [ 0, M- 1] .
ms g_d = r andi nt ( Pd, 1, M) ;
% Us e s quar e c ons t el l at i on QASK met hod f or modul at i on.
ms g_a = modmap( ms g_d, 1, Fs , ' qas k' , M) ;
% As s ume t he c hannel e qui val e nt t o a r ai s e d cos i ne f i l t er .
r cv _a = r cos f l t ( ms g_a, 1, Fs , ' Fs ' ) ;
% Compar e t he s i gnal be f or e and af t e r r ai s ed c os i ne f i l t e r .
pl ot ( [ 0: 1/Fs : Pd- 1/Fs ] , ms g_a, [ 0: 1/Fs : Pd- 1/Fs ] , r c v_a)
% Pl ot t he e ye - pat t e r n di agr am of t he r e ce i v ed s i gnal .
e ye s c at ( r cv _a, 1, Fs , 0, 10) ;
You must tune the fi fth par ameter i n the above e ye s c at command to make the
D-poi nt l i ne (the l i ne that l ocates the deci si on poi nt) i n the eye-pattern di agr am
cr oss over the eye at the eyes most wi del y opened poi nt.
% Us e t he of f s et i nf or mat i on f or di gi t al demappi ng.
r cv _d = demodmap( r cv _a, 1, [ 10, 10] , ' qas k' , 16) ;
% Symbol i c e r r or anal y s i s
s ymer r ( ms g_d, r cv _d)
ans =
0
3 Tutorial
3-10
The fi gure generated by the pl ot command i s a compar i son between the
tr ansmi tted message and the r ecei ved si gnal . I n the fi gur e, the sol i d l i nes ar e
the tr ansmi tted di gi tal si gnal ; the dotted cur ves are the recei ved si gnal :
The eye-pattern di agram r epeatedl y over l ays the r ecei ved si gnal over the
di gi tal transmi ssi on peri od. The fi gur e i s generated by the command e ye s c at .
I t i s cl ear that the eye i s wi del y opened at the D-poi nt l i ne.
0 0.05 0.1 0.15 0.2 0.25 0.3
4
2
0
2
4
0 0.001 0.002 0.003 0.004 0.005 0.006 0.007 0.008 0.009 0.01
4
3
2
1
0
1
2
3
4
DPoint
time (second)
a
m
p
l
i
t
u
d
e
EyePattern Diagram
Signal G enerators and D isplay D evices
3-11
Sca tter Plots
The scatter pl ot i s cl osel y rel ated to the eye-pattern di agram pl ot. The scatter
pl ot recor ds the r ecei ved data val ue at the deci si on poi nt. I n the MATLAB
functi on l i br ary, you can use the functi on e ye s c at to generate scatter pl ots. I n
Si mul i nk, you can use the Scatter Pl ot bl ock.
The pl ots bel ow compare two scatter pl ots that were generated usi ng two
di ffer ent offset poi nts i n the computati on. The fi r st, whi ch i s shown i n the
l eft-hand si de of the fi gure, has shi fted one data poi nt from the opti mal deci si on
poi nt. The second, whi ch i s shown at the ri ght-hand si de of the fi gure, has the
deci si on poi nt exactl y at the opti mal poi nt:
The scatter pl ot for a two-col umn vector i s a two-di mensi onal pl ot wi th the
x-axi s equal l i ng the i n-phase component and the y-axi s equal l i ng the
quadrature component.
The commands used i n generati ng the fi gur e ar e:
e ye s c at ( r cv _a, Fd, Fs , 9, ' . ' ) ;
e ye s c at ( r cv _a, Fd, Fs , 10, ' . ' ) ;
Refer to the Eye-Patter n and Scatter Pl ot bl ocks i n the Si mul i nk reference
pages for more i nformati on on how to generate eye-patter n and scatter pl ot
di agr ams.
3 2 1 0 1 2 3
3
2
1
0
1
2
3
Q
u
a
d
r
a
t
u
r
e
Scatter plot
InPhase
3 2 1 0 1 2 3
3
2
1
0
1
2
3
Q
u
a
d
r
a
t
u
r
e
Scatter plot
InPhase
3 Tutorial
3-12
Er r or - Ra te Ana lysis
Er ror-r ate anal ysi s i s frequentl y used to eval uate the qual i ty of a
communi cati on system desi gn or the per for mance of a speci al techni que or
al gori thm. The number of error bits i s the number of bi t err ors resul ti ng from
compari ng the message sent to the message r ecei ved. The bit error rate i s the
number of bi t er ror s di vi ded by the total number of bi ts tr ansmi tted. The
number of symbol errors and the symbol error rate are defi ned si mi l arl y on the
tr ansmi tted symbol l evel .
I n the MATLAB functi on l i brar y, there ar e two functi ons, s ymer r and bi t e r r ,
dedi cated to symbol -err or number and er ror-r ate computati on. I n the Si mul i nk
bl ock l i br ar y, there i s an Err or -Rate Meter bl ock to di spl ay the symbol to
symbol compari son between the sender and the recei ver(s) and to compute the
symbol er ror number , symbol err or rate, bi t er ror number , and bi t err or rate.
A snapshot of the Er ror -Rate Meter i s shown i n the fi gur e bel ow:
As i ndi cated i n the fi gure, after 7284 bi ts tr ansmi tted, the bl ock detects 318
err or bi ts i n r ecei ver 1. The er ror rate i s:
318/7284 = 0.043657
The bl ock detects 30 err or bi ts i n recei ver 2; the er ror r ate i s 0.004118.
Number of symbol er ror s and
err or rate
Number of bi t er r or s and er ror r ate
Symbol to symbol compar i son
between sender and r ecei ver s
Er ror s i n tr ansmi ssi on
Source C oding
3-13
Source Coding
The Communi cati ons Tool box i ncl udes some basi c functi ons for sour ce codi ng.
Sour ce codi ng, al so known as quanti zati on or si gnal formatti ng, i ncl udes the
concepts of anal og-to-di gi tal conversi on and data compressi on.
Sour ce codi ng di vi des i nto two basi c pr ocedur es: source encodi ng and source
decodi ng. Sour ce encodi ng converts a source si gnal i nto a di gi tal code usi ng a
quanti zati on method. The sour ce coded si gnal i s r epr esented by a set of
i ntegers {0, 1, 2, ..., N-1}, wher e N i s fi ni te. Source decodi ng recovers the
ori gi nal i nfor mati on si gnal sequence usi ng the source coded si gnal . Thi s
tool box i ncl udes two source codi ng quanti zati on methods: scal ar quanti zati on
and predi cti ve quanti zati on. A thi rd sour ce codi ng method, vector
quanti zati on, i s not i ncl uded i n thi s tool box.
Scalar Quantization
Scal ar quanti zati on i s a process that assi gns a si ngl e val ue to i nputs that are
wi thi n a speci fi ed range. I nputs that fal l i n a di fferent r ange of val ues are
assi gned a di ffer ent si ngl e val ue. An anal og si gnal i s i n effect di gi ti zed by
3 Tutorial
3-14
scal ar quanti zati on. For exampl e, a si ne wave, when quanti zed, wi l l l ook l i ke a
r i si ng and fal l i ng stai r step:
Scal ar quanti zati on r equi r es the use of a mappi ng of N conti guous regi ons of
the si gnal r ange i nto N di screte val ues. The N regi ons ar e defi ned by a
par ti ti oni ng that consi sts of N-1 di sti ncti on parti ti on val ues wi thi n the si gnal
r ange. The par ti ti on val ues ar e ar ranged i n ascendi ng order and assi gned
i ndi ces r angi ng fr om 1 to N-1. Each regi on has an i ndex that i s deter mi ned by
thi s for mul a:
For a si gnal val ue x, the i ndex of the corr espondi ng regi on i s i ndx(x).
To i mpl ement scal ar quanti zati on you must speci fy a l ength N-1 vector
partition and a l ength N vector codebook. The vector par ti ti on, as i ts name
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
1.5
1
0.5
0
0.5
1
1.5
Time (sec)
A
m
p
l
i
t
u
d
e
Quantized sine wave
indx x ( )
0 x partition 1 ( )
i partition i ( ) x partition i 1 + ( ) <
N 1 partition N 1 ( ) x <

'

=
Source C oding
3-15
i mpl i es, di vi des the si gnal i nput r ange i nto N regi ons usi ng N-1 parti ti on
val ues. The par ti ti on val ues must be i n stri ctl y ascendi ng or der . The codebook
i s a vector that assi gns a val ue, typi cal l y ei ther an endpoi nt of the regi on or
some average val ue of the i nterval , to each regi on defi ned i n the par ti ti on.
Si nce each r egi on must have an assi gned output val ue, the l ength of the
codebook must equal the l ength of the par ti ti on. Another way to vi ew thi s i s
that the codebook functi ons as a tabl e l ookup wi th each el ement assi gned to a
parti ti on.
The i ndex val ue indx(x) i s the output of the quanti zati on encode functi on. The
codebook contai ns the val ues that cor respond to sampl e poi nts. Ther e i s no
functi on for quanti zati on decodi ng, whi ch i s si mpl y constructi ng the quanti zed
si gnal usi ng the stream of i ndex val ues output by the quanti zer . Construct the
quanti zed si gnal by usi ng the MATLAB command:
y = c odebook( i ndx+1) ;
I n gener al , a codebook has the fol l owi ng r el ati on wi th the vector parti ti on:
The qual i ty of the quanti zati on, cal l ed the di stor ti on, i s the mean-square err or
between the ori gi nal si gnal data s i g and the quanti zed si gnal quan:
where M i s the number of sampl es of the source si gnal s i g.
codebook 1 ( ) parti ti on 1 ( ) codebook 2 ( ) partition 2 ( )
... codebook N 1 ( ) parti ti on N 1 ( ) codebook N ( )
di stor ti on
1
M
----- si g i ( ) qu an i ( ) ( )
2
i 1 =
M

=
3 Tutorial
3-16
The computati on pr ocedur e for the quanti zati on source codi ng and decodi ng i s
shown i n the fi gur e bel ow:
The dashed square at the top of thi s fi gure i s the sour ce encode al gor i thm,
whi ch assi gns an i ndex after deci di ng i n whi ch regi on the i nput si gnal val ue
fal l s. The dashed squar e i n the mi ddl e of the fi gure i s the quanti zati on decode
al gori thm, whi ch maps the i nput i ndex to whatever val ue the codebook assi gns
to that par ti cul ar i ndex. The dashed squar e at the bottom of the fi gure i s the
di stor ti on computati on, whi ch cal cul ates a cumul ati ve aver age i n whi ch M i s
the total number of poi nts used i n the computati on.
The MATLAB functi on quant i z computes al l thr ee outputs shown i n the above
fi gure. The Si mul i nk Scal ar Quanti zer bl ock i s avai l abl e i n the sour ce code
subl i br ar y.
Tr a ining of Pa r ti ti on a nd Codebook Pa r a meter s
The key functi ons i n quanti zati on ar e the assi gnment of the par ti ti on and
codebook par ameters. I n l ar ge si gnal sets wi th a fi ne quanti zati on scheme, the
> partition(1)
> partition(2)
> partition(N-1)
+
indx
codebook(indx)
quant
sig
source encode
quantization decode
+
- +
(.)
2
Memory
/M
+
distor
distortion computation
Source C oding
3-17
sel ecti on of al l the cor rect par ameters can be tedi ous. I n the Communi cati ons
Tool box you can tr ai n these two par ameters by usi ng the MATLAB functi on
l l oyds . To trai n the parameter s, you must prepar e a trai ni ng set, whi ch
typi cal l y r epresents functi on i nput data. The functi on l l oyds fi nds the
parti ti on and codebook par ameter vector s by mi ni mi zi ng the di storti on usi ng
the provi ded tr ai ni ng data. Here i s an exampl e of the data tr ai ni ng for a
si nusoi dal si gnal :
N = 2^3; % t hr ee bi t s t r ans f e r channel
t = [ 0: 1000] pi /50;
s i g = s i n( t ) ; % one compl et e pe r i od of s i nus oi dal s i gnal
[ par t i t i on, c odebook] = l l oy ds ( s i g, N) ;
[ i ndx , quant , di s t or ] = quant i z ( s i g, par t i t i on, codebook) ;
pl ot ( t , s i g, t , quant , ' - - ' ) ;
I n the above commands, s i g i s a si nusoi dal si gnal to be quanti zed. The peak
ampl i tude of the i nput si gnal must be one. The tr ai ned codebook and the
parti ti on can be used for si nusoi dal si gnal s of any fr equency. The above code
gener ates a fi gur e that compares the ori gi nal si gnal (the smooth curve) to the
quanti zed si gnal (the di gi tal cur ve):
The decodi ng procedure i s si mpl e usi ng the basi c MATLAB computati on
format. Use the fol l owi ng command to obtai n the decoded resul t:
quant = c ode book( i ndx+1)
0 10 20 30 40 50 60 70
1
0.5
0
0.5
1
3 Tutorial
3-18
Companders
The quanti zati on di scussed above i s l i near . I n cer tai n appl i cati ons, you may
need to quanti ze a si gnal based on the power l evel of the i nput si gnal . I n thi s
case, i t i s common to use a l ogar i thm computati on before the quanti zati on
operati on. Si nce a si mpl e l ogari thm computati on can onl y handl e a posi ti ve
si gnal , some modi fi cati on of the i nput si gnal i s needed. The l ogari thm
computati on i s known as a compressor. The rever se computati on of a
compr essor i s cal l ed an expander. The combi nati on of a compressor and
expander i s cal l ed a compander (compress and expand). Thi s tool box suppor ts
two companders: the -l aw and A-l aw companders. The sel ecti on of ei ther
method i s a matter of user preference.
The MATLAB functi on compand i s desi gned for compander computati on. The
Si mul i nk bl ock l i brar y i ncl udes four bl ocks for the -l aw and A-l aw compander
computati ons: -Law Compressor , -Law Expander, A-Law Compressor, and
A-Law Expander.
- la w Compa nder
For a gi ven si gnal x, the output y of the -l aw compressor i s
where V i s the peak val ue of si gnal x, whi ch i s al so the peak val ue of y. i s the
-l aw par ameter of the compander. The functi on l og i s the natural l ogari thm
and s gn i s the si gn functi on.
The -l aw expander i s the i nver se of the compressor:
The MATLAB functi on for -l aw compandi ng i s compand. The corr espondi ng
Si mul i nk -Law Compr essor and -Law Expander bl ocks al so suppor t -l aw
compandi ng.
y
V 1 x V + ( ) l og
1 + ( ) l og
--------------------------------------------- x ( ) sgn =
x
V

---- e
y 1 + ( ) l og V
1 + ( ) y ( ) sgn =
Source C oding
3-19
A- la w Compa nder
For a gi ven si gnal x, the output y of the A-l aw compressor i s
where V i s the peak val ue of si gnal x, whi ch i s al so the peak val ue of y. A i s the
A-l aw parameter of the compander . The functi on l og i s the natur al l ogar i thm
and s gn i s the si gn functi on.
The A-l aw expander i s the i nverse of the compressor :
The MATLAB functi on for A-l aw compandi ng i s compand. The corr espondi ng
Si mul i nk -Law Compr essor and -Law Expander bl ocks al so suppor t -l aw
compandi ng.
Predictive Quantization
The quanti zati on i ntr oduced i n the Scal ar Quanti zati on secti on i s usual l y
i mpl emented when there i s no a priori knowl edge about the tr ansmi tted si gnal .
I n practi ce, a communi cati ons engi neer often has some a priori i nfor mati on
about the message si gnal s. An engi neer can use thi s i nfor mati on to predi ct the
next si gnal to be transmi tted based on past si gnal tr ansmi ssi ons; i .e., he or she
can use the past data set x={x(k-m),...,x(k-2), x(k-1)}to predi ct x(k) by usi ng
some functi on f(.). The most common way to i mpl ement pr edi cti ve quanti zati on
i s to use the di ffer enti al pul se code modul ati on (DPCM) method. The
Communi cati ons Tool box pr ovi des the tool s necessary to i mpl ement a DPCM
predi cti ve quanti zer .
y
A x
1 A l og +
---------------------- x ( ) sgn
V 1 A x V l og + ( )
1 A l og +
---------------------------------------------- x ( ) sgn
for 0 x A V
for A V x V <

'

=
x
y
1 A l og +
A
---------------------- y ( ) sgn
e
y 1 A l og + ( ) V 1 V
A
---- y ( ) sgn
for 0 y
V
1 A l og +
----------------------
for
V
1 A l og +
---------------------- y V <

'

=
3 Tutorial
3-20
Dif fer enti a l Pulse Code M odula ti on
Usi ng the past data set and predi ctor as descr i bed above, the predi cted val ue
i s assumed to be
where k i s the computati on step i ndex. The functi on f(.) i s cal l ed the predictor;
the i nteger m i s the pr edi cti ve order. The pr edi cti ve err or i s
quanti zed by usi ng the method di scussed i n the Scal ar Quanti zati on secti on.
The str uctur e of pr edi cti ve quanti zati on i s:
Thi s method i s known as the di ffer enti al pul se code modul ati on method
(DPCM). I n the fi gur e, i ndx(k) i s the sour ce encoded i ndex, and y(k) i s the
quanti zed output. The DPCM method tr ansfer s the bi t l ength r educed i ndx(k)
i nstead of the real data x(k). At the recei vi ng si de, a quanti zati on decoder
r ecovers the quanti zed y(k) fr om i ndx(k).
The fi gure bel ow shows the quanti zati on source decodi ng method:
The predi ctor must be the same one used i n the encodi ng fi gur e.
Thi s tool box uses a l i near predi ctor:
x

k ( ) f x k m ( ) ... x k 2 ( ) x k 1 ( ) , , , ( ) =
e k ( ) x k ( ) x

k ( ) =
Quantization
Source encode
Predictor
source input x(k)
e(k)
-
+
+
+
source encoded index indx(k)
quantized y(k)
x(k)
^
Quantization
source decode
Predictor
source encoded index indx(k)
quantized y(k)
x k ( ) p = 1 ( )x k 1 ( ) ... p m 1 ( )x k m 1 + ( ) p m ( )x k m ( ) + + +
Source C oding
3-21
The transfer functi on of thi s pr edi ctor i s repr esented by a pol ynomi al . The
vector represents the fi ni te
i mpul se r esponse (FI R) transfer functi on:
A speci al case of the DPCM sour ce code method i s the wi del y used
del ta-modul ati on method, i n whi ch the l i near pr edi ctor i s a fi r st order predi ctor
wi th
The Communi cati ons Tool box provi des MATLAB functi ons dpcmenco and
dpc mdec o for the sour ce encodi ng and sour ce decodi ng usi ng the DPCM
method. Thi s tool box al so pr ovi des the functi on dpc mopt , whi ch uses a set of
tr ai ni ng data to gener ate an opti mal transfer functi on of the predi ctor p_t r ans ,
the par t i t i on, and the c odebook. The tr ai ni ng data r epr esents the i nput
si gnal used i n the DPCM quanti zati on. For exampl e, you can use dpcmopt to
fi nd the parameter s needed to encode/decode a si nusoi dal si gnal usi ng the
del ta-modul ati on method. Thi s exampl e i s a conti nuati on of the exampl e
provi ded i n the Scal ar Quanti zati on secti on:
% Gener at e t he opt i mal pr edi c t i ve t r ans f er f unc t i on,
% t he par t i t i on, and t he code book.
[ p_t r ans , par t i t i on, c ode book] = dpcmopt ( s i g, 1, N) ;
% Enc ode t he s i gnal us i ng DPCM.
i ndx = dpcme nc o( s i g, codebook, par t i t i on, p_t r ans ) ;
% Dec ode us i ng DPCM.
quant = dpc mde co( i ndx, c odebook, p_t r ans ) ;
% Compar e t he or i gi nal and t he quant i z e d s i gnal .
pl ot ( t , s i g, t , quant , ' - - ' )
p_trans
0 p 1 ( ) , ... p k m 1 + ( ) p k m ( ) ,
=
3 Tutorial
3-22
Note that the sampl e ti me i s i mportant i n the DPCM quanti zati on. The fi gur e
bel ow shows the pl ot generated from the code:
The pr edi ctor must be the same one used i n the encodi ng fi gur e. Compari ng the
r esul t generated i n thi s exampl e to the one generated by scal ar quanti zati on,
noti ce that the DPCM quanti zati on i s of much better qual i ty. The di stor ti on
her e i s 6.2158e-5, whi ch i s much l ower than the di stor ti on val ue of 5.002e-3
achi eved by the scal ar quanti zati on. Both methods used three bi t symbol s i n
the quanti zati on.
Si mul i nk bl ocks for the DPCM encode and decode ar e avai l abl e i n the source
code subl i br ary. A si mpl e bl ock di agram exampl e of usi ng DPCM encode and
decode bl ocks for source codi ng i s:
Thi s bl ock di agram encodes a gener ated si gnal usi ng the DPCM method and
then recover s the si gnal by DPCM decodi ng. The scope i n the bl ock di agr am
compares the ori gi nal si gnal wi th the quanti zed si gnal . The curve di spl ayed on
the scope i s the same as the curve shown i n the pl ot gener ated fr om the
MATLAB code.
0 10 20 30 40 50 60 70
1.5
1
0.5
0
0.5
1
1.5
Signal
generator
Mux
Mux1
Scope DPCM
decode
DPCM
encode
Error-C ontrol C oding
3-23
Error-Control Coding
Err or-contr ol codi ng techni ques are used to detect and/or corr ect er ror s that
occur i n the message transmi ssi on i n a di gi tal communi cati on system. The
tr ansmi tti ng si de of the er ror -contr ol codi ng adds r edundant bi ts or symbol s to
the or i gi nal i nformati on si gnal sequence. The r ecei vi ng si de of the er ror-contr ol
codi ng uses these redundant bi ts or symbol s to detect and/or cor rect the er ror s
that occur red duri ng tr ansmi ssi on. The tr ansmi ssi on codi ng process i s known
as encoding, and the recei vi ng codi ng process i s known as decoding.
There are two major cl asses i n er ror -contr ol code: bl ock and convol uti onal . I n
bl ock codi ng, successi ve bl ocks of K i nformati on (message) symbol s ar e for med.
The codi ng al gor i thm then tr ansfor ms each bl ock i nto a codeword consi sti ng of
N symbol s wher e N>K. Thi s str uctur e i s cal l ed an (N, K) code. The r ati o K/N i s
cal l ed the code rate. A key poi nt i s that each codeword i s for med i ndependentl y
from other codewor ds.
Convol uti onal codes di ffer from bl ock codes i n that there are no i ndependent
codewor ds. The encodi ng pr ocess can be envi si oned as a sl i di ng wi ndow, M
symbol s wi de, whi ch moves over the sequence of i nfor mati on symbol s i n steps
of K symbol s. M i s cal l ed the constraint length of the code and K i s usual l y
equal to 1. Wi th each step of the sl i di ng wi ndow, the encodi ng process
gener ates N symbol s based on the M symbol s vi si bl e i n the wi ndow. The code
rate i s K/N.
There are two mai n types of decodi ng used wi th er ror-contr ol codes: al gebr ai c
and pr obabi l i sti c. Al gebrai c decodi ng i s based on the mathemati cal properti es
of l i near al gebr a and Gal oi s (fi ni te) fi el ds. I t i s usual l y per formed on bl ock
codes. Ther e i s a set of MATLAB functi ons for Gal oi s fi el d cal cul ati ons i n thi s
tool box. The most common type of pr obabi l i sti c decodi ng i s Vi terbi decodi ng,
whi ch i s al most al ways per for med on convol uti onal codes. Thi s tool box
provi des an easy-to-use user i nter face that enabl es you to use Si mul i nk bl ock
di agr ams to construct a convol uti onal code tr ansfer functi on. The decodi ng of
convol uti onal codes i n thi s tool box uses the Vi ter bi al gori thm.
An err or-control code i s a linear code i f the transmi tted si gnal s ar e a l i near
functi on of the i nformati on symbol s. The code i s cal l ed systemati c code i f the
i nfor mati on symbol s are transmi tted wi thout bei ng al ter ed. Most bl ock codes
ar e systemati c, whereas most convol uti onal codes are nonsystemati c. Al most
al l codes used for er ror contr ol ar e l i near. The symbol s i n a code can be ei ther
bi nary or nonbi nary. Bi nar y symbol s ar e the fami l i ar 0 and 1. Nonbi nary codes
3 Tutorial
3-24
ar e usual l y el ements of a Gal oi s fi el d GF(p
M
). There ar e p
M
possi bl e val ues for
these symbol s wher e p i s a pr i me number and M i s a posi ti ve i nteger. The val ue
of p i s usual l y 2. Reed-Sol omon codes ar e the most popul ar nonbi nary codes.
You can execute al l encode computati ons by cal l i ng the functi on encode. The
format for e nc ode i s
c ode = e nc ode( ms g, N, K, met hod, opt ) ;
where ms g i s the message si gnal (or i nfor mati on si gnal sequence), N i s the
codewor d l ength, and K i s the message l ength (or number of i nfor mati on bi ts).
met hod i s a str i ng that speci fi es what type of encodi ng pr ocess to use, and opt
i s an opti onal par ameter used i n some of the methods. The tabl e bel ow l i sts the
method str i ngs, thei r meani ng, and the corr espondi ng opt parameter :
We encour age you to understand the err or-contr ol codi ng techni ques. However,
you do not need to be an expert i n the codi ng methods to set the par ameters.
The rest of thi s secti on provi des a bri ef di scussi on and a few exampl es that
expl ai n how to use the er ror -control codi ng functi onal i ty of thi s tool box.
Thi s exampl e uses a codeword l ength 15 and 11 i nformati on bi ts to encode a
bi nary message. The exampl e uses BCH code for the encodi ng process:
N = 15;
K = 11;
r ow_num = 100;
ms g = r andi nt ( Kr ow_num, 1, 2) ;
c ode = e nc ode( ms g, N, K, ' bc h' ) ;
Method Meaning opt Parameter
hammi ng Hammi ng code Not used
bl ock Li near bl ock code Generator matri x
c yc l i c Cycl i c code Generator pol ynomi al
bch BCH code Not used
r s Reed-Sol omon code Not used
c onvol ut i on Convol uti onal code Octal form tr ansfer functi on
Error-C ontrol C oding
3-25
Decodi ng i s the i nverse of the encodi ng process. Use the MATLAB functi on
de c ode for al l decodi ng processes. The format for functi on dec ode i s:
ms g = dec ode ( c ode, N, K, met hod, opt 1, opt 2) ;
The decode opti onal parameter s var y dependi ng what codi ng method you use.
You must use the same method i n the e nc ode and dec ode functi ons to recover
the i nfor mati on si gnal sequence. Conti nui ng the encodi ng exampl e, assume
ther e i s some transmi ssi on err or i n the channel . As a test, r andoml y add one
bi t err or to each codeword:
noi s = r andbi t ( r ow_num, N, . 3) ;
c ode = r e m( c ode( : ) +noi s ( : ) , 2) ;
Decode the message by typi ng:
r cv = dec ode ( c ode, N, K, ' bc h' )
The bi t er ror i n the decode i s:
e r r = bi t er r ( r cv , ms g)
e r r =
0
There i s a MATLAB bl ock subl i br ary contai ni ng functi ons dedi cated to the
err or-control codi ng/decodi ng pr ocess. These functi ons ar e al so avai l abl e to the
Si mul i nk bl ock l i brary.
Vector vs. Sequential Input/ Output
There are two mai n i nput/output for mats for the bl ocks i n the Er ror-Control
Codi ng subl i br ar y: the vector i nput/output format and the sequenti al i nput/
output for mat.
3 Tutorial
3-26
Vector I nput/ O utput For ma t
For vector i nput/output format, the encode bl ocks accept l ength K vectors as
thei r i nput si gnal s and output l ength N codewor d vectors. The i nput/output
l ength for decodi ng bl ocks i s the rever se of the encodi ng bl ocks. A decode bl ock
accepts a l ength N codewor d vector and outputs a l ength K recovered message.
Thi s fi gur e shows the vector i nput/output format for encodi ng and decodi ng a
message:
Vector Input/ O utput Forma t Block Dia gra m. You can bui l d a Si mul i nk bl ock di agr am
to si mul ate the BCH code usi ng the vector i nput/output for mat. A si mpl e bl ock
di agram i s shown bel ow:
Transmitting
Decode Encode Length K
message
Length K
message
Length N
codeword
Length N
codeword
Receiving
Vec to sca
converter
Error Rate
Meter
BCH
encode
Sampled
read
variable
1
BCH
decode
Binary err
channel
Vec to sca
converter
Error-C ontrol C oding
3-27
I n the bl ock di agr am, the Sampl ed Read Vari abl e bl ock i s the data source. The
BCH encode and decode bl ocks are dedi cated to the encodi ng and decodi ng
processes respecti vel y. The Bi nar y Err Channel bl ock si mul ates a di gi tal
tr ansmi ssi on channel , whi ch adds er ror s i nto the encoded bi nar y si gnal . The
Err or Rate Meter bl ock compar es the source data and the decoded data and
cal cul ates the err or r ate. The si mul ati on er ror-r ate data i s shown i n the fi gure
opened fr om the err or-rate meter . A snapshot of the err or -rate meter i s:
Sequentia l I nput/ O utput For ma t
I n the sequenti al i nput/output for mat, the bl ocks automati cal l y buffer up the
sequenti al i nput si gnal i nto a vector si gnal . The output mechani sm
automati cal l y buffers down the vector si gnal to a sequenti al si gnal . The buffer
up/down procedure causes del ays. The del ay ti me i s the i nput buffer l ength
mul ti pl i ed by the i nput sampl i ng ti me, or equi val entl y, i t i s the output buffer
l ength mul ti pl i ed by the output sampl i ng ti me. Refer to the Si mul i nk r efer ence
page for each bl ock for i ts del ay ti me. Note that the sampl e ti me for an i nput
si gnal i s di fferent from the sampl e ti me for an output si gnal . The sampl e ti me
for the encode bl ock i s based on the bl ock i nput sequence and the sampl e ti me
for the decode bl ock i s based on the bl ock output sequence. The fi gure bel ow
shows a sequenti al i nput/sequenti al output encodi ng bl ock di agr am.
3 Tutorial
3-28
The sequenti al i nput/output decodi ng process i s the exact i nverse of the
encodi ng pr ocess.
To obtai n a corr ect decode r esul t, the decode method and par ameters must
match the encode counter part exactl y, except for ti mi ng and phase offsets,
whi ch may di ffer .
Ex a mple of the Sequentia l Input/ O utput Forma t. A sequenti al i nput/sequenti al
output exampl e can be bui l t to si mul ate the BCH code encodi ng and decodi ng
pr ocess. The bl ock di agr am for the sequenti al i nput/sequenti al output bl ock
di agram i s:
To l ear n how to set the parameter s corr ectl y, see the Si mul i nk r efer ence
entri es on BCH bl ock sequenti al code/decode bl ocks. See Chapter 5, MATLAB
Functi on Refer ence, for descri pti ons of the Gal oi s fi el d computati on functi ons.
Length K
message
Length N
codeword
Encode
vector I/O
codeword output
time-sequential
message input
time-sequential
b
u
f
f
e
r
-
u
p
b
u
f
f
e
r
-
d
o
w
n
d
i
r
e
c
t
i
o
n
d
i
r
e
c
t
i
o
n
Length K
Length N
When input buffer is filled, the filled-up signal triggers the processing of the following:
encode, empty input buffer, and refresh output buffer. The time delay of this block fills up
Output buffer
Input buffer
Encode
sequential I/O
the input buffer, which equals the input_sample_time K or the output_sample_time N.
Note that the input_sample_time need not equal the output_sample_time.
Sampled
read
variable
BCH
encode
Binary err
channel
BCH
decode
Error Rate
Meter
Error-C ontrol C oding
3-29
Error-Control Coding Library Blocks
The bl ocks i ncl uded i n the err or -control codi ng l i brary and the categor i es they
bel ong to are as fol l ows. The encodi ng computati ons i n the fol l owi ng l i st can be
done by usi ng functi on e nc ode. The decodi ng computati ons i n the fol l owi ng l i st
can be done by usi ng functi on de code .
Category Blocks
Li near Bl ock Code Li near Bl ock Encode Vector I n/Out
Li near Bl ock Decode Vector I n/Out
Li near Bl ock Encode Sequenti al I n/Out
Li near Bl ock Decode Sequence I n/Out
Hammi ng Code Hammi ng Encode Vector I n/Out
Hammi ng Decode Vector I n/Out
Hammi ng Encode Sequenti al I n/Out
Hammi ng Decode Sequenti al I n/Out
Cycl i c Code Cycl i c Encode Vector I n/Out
Cycl i c Decode Vector I n/Out
Cycl i c Encode Sequenti al I n/Out
Cycl i c Decode Sequenti al I n/Out
BCH Code BCH Code Vi ew Tabl e
BCH Encode Vector I n/Out
BCH Decode Vector I n/Out
BCH Encode Sequence I n/Out
BCH Decode Sequence I n/Out
3 Tutorial
3-30
Linear Block Codes
Li near bl ock codi ng i s a generi c codi ng method. Other codi ng methods, such as
Hammi ng and BCH codes, are speci al cases of l i near bl ock codi ng. The
codewor d vector of a l i near bl ock code i s a l i near mappi ng of the message
vector. The codewor d v and the message u have the r el ati onshi p .
where G i s a K-by-N matri x wi th al l el ements i n GF(2). G i s known as the
generator matri x.
Li near bl ock code i s cal l ed a systemati c l i near code i f the generator matr i x has
the form G =[P, I ], where P i s an (N-K)-by-K matr i x and I i s a K-by-K i denti ty
matri x. (Note that some author s defi ne the gener ator matri x as [I , P].) A
systemati c l i near code render s a l ength K message i nto a l ength N codewor d
where the l ast K bi ts are exactl y the or i gi nal message and the fi r st (N-K) bi ts
ar e r edundant. These redundant bi ts serve as par i ty-check di gi ts. Any l i near
Reed-Sol omon Code Reed-Sol omon Encode I nteger Vector I n/Out
Reed-Sol omon Decode I nteger Vector I n/Out
Reed-Sol omon Encode Bi nary Vector I n/Out
Reed-Sol omon Decode Bi nar y Vector I n/Out
Reed-Sol omon Encode I nteger Sequence I n/
Out
Reed-Sol omon Decode I nteger Sequence I n/Out
Reed-Sol omon Encode Bi nary Sequence I n/Out
Reed-Sol omon Decode Bi nar y Sequence I n/Out
Convol uti onal Code Convol uti onal Encode Vector I n/Out
Convol uti onal Decode Vector I n/Out
Convol uti onal Encode Sequenti al I n/Out
Convol uti onal Decode Sequenti al I n/Out
Category Blocks
v uG =
Error-C ontrol C oding
3-31
code can be mapped i nto a systemati c l i near code, known as the equivalent
systematic linear code.
The recover y of the l ength K message fr om the codewor d i nvol ves the
cal cul ati on of a matr i x cal l ed the syndr ome. The syndr ome i s a matri x that,
when mul ti pl i ed by the codeword vector, produces the ori gi nal message pl us a
l ength (N-K) set of er ror -corr ecti on bi ts. Wi thi n the l i mi tati ons of the desi gned
code, the syndr ome detects the number of er ror s contai ned i n the recei ved
message.
Assume that the recei ved sequence r i s the codewor d v pl us an er ror sequence
e i n the channel .
The decodi ng process i ncl udes these four steps:
1 Compute the syndr ome of r.
2 Locate the err or e by usi ng the syndr ome.
3 Decode the r ecei ved vector i nto the code vector v=r+e.
4 Recover the message vector from the reconstr ucted codewor d vector v.
The syndr ome i s computed by wher e H i s cal l ed a parity-check
matrix. H i s a nul l space matr i x of the gener ator matri x G. H i s a (N-K)-by-K
matr i x, whi ch has the pr oper ty that
Si nce r=v+e, v=uG, and GH
T
=0, we have s=rH
T
=eH
T
, whi ch means that the
syndrome i s a l i near functi on of the transmi ssi on err or. Thi s tool box pr ovi des
a functi on cal l ed ge n2par to compute H fr om G for systemati c l i near bl ock code.
The er ror l ocati on can be determi ned by a l ogi c ci r cui t truth tabl e usi ng the
syndrome. I n the tool box, a si ngl e er ror-detecti on tr uth tabl e can be cal cul ated
by usi ng the command ht r ut ht b. Once e i s known, v can be cal cul ated si mpl y
by usi ng GF(2) addi ti on; that i s, addi ti on usi ng the XOR l ogi cal oper ator. I n
order to r ecover the message vector from the codeword, a matr i x Q wi th GQ=I
has to be found, where I i s a K-by-K i denti ty matri x. For a systemati c (N, K)
code, Q i s
r v e + =
s rH
T
=
GH
T
0 =
Q
0
K N K ( )
I
K K
=
3 Tutorial
3-32
Ex a mple of a Linea r Block Code
I n thi s exampl e, assume the gener ator matr i x i s
whi ch means that the l i near bl ock code i s a (7, 4) code. An encode/decode
pr ocess usi ng the MATLAB functi ons e ncode and dec ode i s:
G = [ [ 1 1 0; 0 1 1; 1 1 1; 1 0 1] , e ye ( 4) ] ;
[ K, N] = s i z e( G) ;
ms g = r andi nt ( K*200, 1, 2) ;
c ode = e nc ode( ms g, N, K, ' bl oc k' , G) ;
c ode_noi s e = r em( c ode +r and( N*200, 1) >. 95, 2) ;
r cv = de code ( c ode_noi s e , N, K, ' bl ock' , ge n2par ( G) ) ;
di s p( [ ' Er r or r at e i n t he r e ce i ve d code : ' , . . .
num2s t r ( s y me r r ( code , c ode_noi s e ) /l e ngt h( code ) ) ] )
Er r or r at e i n t he r ec ei ve d code: 0. 05
di s p( [ ' Er r or r at e af t er dec ode : ' , . . .
num2s t r ( s y me r r ( ms g, r cv ) /l engt h( ms g) ) ] )
Er r or r at e af t er de code : 0
Hamming Codes
A Hammi ng code i s a l i near bl ock code. I n thi s tool box, the codeword l ength N
of Hammi ng code i s a fi xed number equal to 2
M
-1, where M i s an i nteger l ar ger
than or equal to 3. M i s al so the pari ty check l ength. The message l ength of
Hammi ng code i s 2
M
-M-1. Hammi ng code i s a si ngl e err or -corr ecti on code,
whi ch means that onl y one-bi t cor recti ons ar e possi bl e per codewor d. A l i st of
some val i d Hammi ng code parameter s (codeword l ength N, message l ength K,
and par i ty check l ength M) i s pr ovi ded i n the tabl e bel ow:
G
1 1 0 1 0 0 0
0 1 1 0 1 0 0
1 1 1 0 0 1 0
1 0 1 0 0 0 1
=
N 7 15 31 63 127 255 511 1023 2047 4095 8191 16383 32767
K 4 11 26 57 120 247 502 1013 2036 4083 8178 16369 32752
M 3 4 5 6 7 8 9 10 11 12 13 14 15
Error-C ontrol C oding
3-33
The generator matr i x and the pari ty check matr i x for Hammi ng code can be
produced by the functi on hammgen. The truth tabl e to fi nd the er ror l ocati on
from the syndrome for Hammi ng code can be found by usi ng the command
ht r ut ht b.
I n communi cati ons theory, i t i s possi bl e to r educe N, the codewor d l ength, i n
cer tai n si tuati ons wher e thr oughput i s an i ssue or when ther e i s mor e
redundancy i n the code than i s necessary for the appl i cati on at hand. The
resul ti ng code i s cal l ed shortened code. Thi s tool box does not suppor t shor tened
code.
Cyclic Codes
Cycl i c code i s a l i near code produced by a cycl i c gener ator pol ynomi al . The
gener ator pol ynomi al f(X) of a (N, K) cycl i c code i s degr ee N-K pol ynomi al over
the GF(2) fi el d. Cycl i c codes are attr acti ve i n that they possess cer tai n
al gebr ai c pr oper ti es that al l ow pr acti cal decodi ng i mpl ementati ons. Thi s
tool box pr ovi des a functi on cy cl pol y to fi nd cycl i c gener ator pol ynomi al s. For
exampl e, you can fi nd al l val i d (15, 9) cycl i c gener ator pol ynomi al s by usi ng:
pl =cy cl pol y ( 15, 9)
pl =
1 0 0 1 1 1 1
1 0 1 1 1 0 1
1 1 1 1 0 0 1
Gi ven a cycl i c pol ynomi al , you can fi nd the cycl i c generator matr i x and
pari ty-check matri x by usi ng the functi on c yc l gen. You have the choi ce of
ei ther ' nor mal ' or ' s y s t emat i c' code. A systemati c cycl i c code i s
recommended for most appl i cati ons.
Wi th the generator matri x and the par i ty-check matr i x avai l abl e, the encode
and decode pr ocedur es are the same as those di scussed i n the Li near Bl ock
Code secti on.
BCH Codes
BCH code i s another l i near bl ock code. Unl i ke Hammi ng codes, BCH code
permi ts mul ti pl e-er ror bi t cor recti ons. BCH code i s named after the i nventors
of the code: Bose, Chaudhur i , and Hocquenghem. The codeword l ength of a
BCH code i s 2
M
-1, wher e M i s an i nteger l ar ger than or equal to 3. The number
of i nfor mati on bi ts i s deter mi ned by the constr ucti on of the cosets of GF(2
M
).
3 Tutorial
3-34
You can use the functi on gf cos e t to generate cosets of GF(2

). For a di scussi on
of what cosets are, r efer to Li n & Costel l o.
BCH Encoding
The err or -cor recti on capabi l i ty of BCH code i s a functi on of the codeword and
the message l engths. There i s no cl osed-for m for mul a for determi ni ng the BCH
code err or -cor recti on capabi l i ty. Thi s tool box pr ovi des the MATLAB functi on
bchpol y to cal cul ate the BCH generator pol ynomi al . Thi s functi on al so
di spl ays the val i d BCH codewor d l ength, message l ength, and err or -cor recti on
capabi l i ty. For exampl e, you can fi nd the val i d message l engths for a gi ven
codewor d l ength by:
bchpol y ( N)
I f N i s not a val i d codeword l ength, the functi on wi l l fi nd the smal l est val i d
codewor d l arger than the gi ven i nteger. For N1023, the functi on bchpol y
pr oduces a l i st of val i d message words and er ror-contr ol capabi l i ty. For
N>1023, the functi on pr ovi des a l i st of val i d message l engths onl y. When the
functi on
bchpol y i s cal l ed wi th no i nput and output var i abl es, i t l i sts the codewor d
l ength, message l ength, and err or-control capabi l i ty for al l codewor d l engths no
l ar ger than 511. The next fi gur e l i sts al l message l engths and er ror-corr ecti on
capabi l i ti es for al l val i d codeword l engths up to 2
11
-1=511:
Error-C ontrol C oding
3-35
Figure 3-1: Message Lengths and Error-Correction Capabilities for Valid
Codeword Lengths in BCH Code
N: code word length; K: message length; T: errorcorrection capability
N K T N K T N K T
7 4 1
15 11 1
7 2
5 3
31 26 1
21 2
16 3
11 5
6 7
63 57 1
51 2
45 3
39 4
36 5
30 6
24 7
18 10
16 11
10 13
7 15
127 120 1
113 2
106 3
99 4
92 5
85 6
78 7
71 9
64 10
57 11
50 13
43 14
36 15
29 21
22 23
15 27
8 31
255 247 1
239 2
231 3
223 4
215 5
207 6
255 199 7
191 8
187 9
179 10
171 11
163 12
155 13
14
139 15
131 18
123 19
115 21
107 22
99 23
91 25
87 26
79 27
71 29
63 30
55 31
47 42
45 43
37 45
29 47
21 55
13 59
9 63
511 502 1
493 2
484 3
475 4
466 5
457 6
448 7
439 8
430 9
421 10
412 11
403 12
394 13
385 14
376 15
367 16
511 358 18
349 19
340 20
331 21
322 22
313 23
304 25
295 26
286 27
277 28
268 29
259 30
250 31
241 36
238 37
229 38
220 39
211 41
202 42
193 43
184 45
175 46
166 47
157 51
148 53
139 54
130 55
121 58
112 59
103 61
94 62
85 63
76 85
67 87
58 91
49 93
40 95
31 109
28 111
19 119
10 121
147
3 Tutorial
3-36
You can obtai n generator pol ynomi al s by usi ng the functi on bchpol y wi th a
val i d codeword l ength and message l ength speci fi ed.
Wi th a gi ven gener ator pol ynomi al , you can use c yc l gen to produce the
generator matr i x and then fol l ow the cycl i c encode pr ocedure for the encodi ng
computati on.
BCH Decodi ng
The decodi ng pr ocedur e for the BCH code i s much more compl i cated than the
encodi ng pr ocess. The decodi ng pr ocess i ncl udes these four steps:
1 Compute syndr ome from the recei ved codeword (codeword corr upted by
noi se).
2 Determi ne the er ror-l ocati on pol ynomi al fr om the syndr ome.
3 Fi nd the roots of the err or-l ocati on pol ynomi al , whi ch are the er ror -l ocati on
number s.
4 Reconstruct the cor rected codewor d and determi ne the message from the
codeword.
The al gor i thm i s r ather compl i cated. Refer to Li n & Costel l o for more
i nfor mati on or see the functi on bchcor e for the i mpl ementati on of BCH
decodi ng.
Reed-Solomon Codes
Reed-Sol omon (RS) codes ar e burst er ror-cor recti on codes. Al l of the other
codi ng methods provi ded i n thi s tool box are random err or-cor recti on codes. A
burst er ror occur s when noi se corr upts sever al consecuti ve bi ts. Burst er ror s
frequentl y occur i n computer data storage access. Because of thi s, RS code i s
wi del y used i n computer data storage envi ronments, especi al l y i n CD-ROM
err or-cor recti on systems.
The theory of Reed-Sol omon code i s based on fi ni te fi el d theory. I n parti cul ar,
the fi el ds used are of the for m GF(q
M
), where q i s any pri me number and M any
posi ti ve i nteger . Thi s tool box suppor ts RS code on GF(2
M
). The el ements of
GF(2
M
) ar e defi ned by a power seri es format, i .e.,
-I nf
,
0
, ,
2
,.... The
message l ength K can be any posi ti ve i nteger smal l er than N, wher e N i s the
codewor d l ength.
Error-C ontrol C oding
3-37
The basi c par ameters of RS code ar e:
Codewor d l ength: N = 2
M
- 1
Number of check symbol s: N-K = 2*T
Err or -cor recti on capabi l i ty: T = fl oor ((N-K)/2)
For an effi ci ent RS code, N-K shoul d be an even number . Wi th the excepti on
that the el ements of RS code are i n GF(2
M
) i nstead of i n GF(2), al l computati on
procedures ar e the same as those for BCH code.
The generator pol ynomi al for RS code i s a degr ee 2*T pol ynomi al wi th i ts
coeffi ci ents i n GF(2
M
). Thi s tool box provi des the MATLAB functi on r s pol y to
produce RS code gener ator pol ynomi al s.
The decode pr ocedur e i s the same as for the BCH code. Refer to Li n & Costel l o
for mor e i nformati on or see the functi on r s c or e for the i mpl ementati on of RS
decodi ng. The data i nput for RS code/decode can be one of the three for ms:
bi nary, i ntegers i n the r ange from 0 to 2
M
-1, or power wi th the el ements i n
GF(2
M
).
Convolutional Codes
Up to now, al l the decodi ng methods di scussed are al gebrai c decodi ng methods,
whi ch are memoryless codes. A memoryl ess code makes decodi ng deci si ons
wi th onl y the curr ent codewor d; code wi th memory uses i nformati on from
previ ousl y r ecei ved codes to make decodi ng deci si ons about the most recentl y
recei ved codeword. Si nce convol uti onal code makes deci si ons about the curr ent
codewor d based on past i nformati on, i t contai ns memor y el ements. To i ncl ude
the memory el ements i n the code, an extr a par ameter M i s used to descri be a
convol uti onal code. The parameter M i s r efer red to as the constraint length of
the code. The constrai nt l ength i s the maxi mum number of i nfor mati on
symbol s upon whi ch the symbol may depend. Two other par ameters ar e needed
to descri be the code. The par ameter N desi gnates the number of symbol s
gener ated by the encoder from any gi ven bl ock of M conti guous i nfor mati on
symbol s. K i s the number of i nformati ons symbol s by whi ch the bl ock i s
advanced each ti me that code symbol s are gener ated. A convol uti onal code so
constr ucted i s cal l ed an (N, K, M) code.
Convol uti onal codes are commonl y used i n appl i cati ons that requi re r el ati vel y
good per for mance wi th l ow i mpl ementati on cost.
3 Tutorial
3-38
The Tr a nsfer Functi ons of Convoluti ona l Codi ng
The convol uti onal code tr ansfer functi on determi nes the structure of the code.
Many di fferent convol uti onal code transfer functi ons may share the same
(N, K, M) number , so exact speci fi cati on of a convol uti onal code r equi r es
knowl edge of i ts tr ansfer functi on. I n thi s tool box, the tr ansfer functi on matri x
for convol uti onal code can be represented by two di fferent for ms: octal and
bi nary. Thi s tool box provi des an i nter face usi ng Si mul i nk bl ock di agrams to
generate a convol uti onal code tr ansfer functi on.
A bl ock di agr am exampl e of a (3, 2, 2) convol uti onal code i s:
Thi s (3, 2, 2) bl ock di agram of a convol uti onal code uses thi s Si mul i nk bl ock
di agram repr esentati on:
XOR
XOR
XOR
Shift
Reg
Shift
Reg.
Shift
Reg.
input output
Error-C ontrol C oding
3-39
Note that fi ve di ffer ent Si mul i nk bl ocks have been used i n the convol uti onal
code structur e defi ni ti on: I npor t, Memory, XOR, and Outport bl ocks. The
functi onal i ty of each bl ock can be found by compari ng the above two fi gur es.
You can convert a Si mul i nk bl ock di agram i nto a tr ansfer functi on matr i x by
usi ng the command s i m2ge n. s i m2ge n converts a Si mul i nk bl ock di agr am to
an octal for m tr ansfer functi on matr i x.
Transfer functi ons for convol uti onal codes can be ei ther l i near or nonl i near . I n
thi s tool box, l i near transfer functi ons fal l i nto thr ee categori es:
bi nar y for m
octal form
state space form
Nonl i near tr ansfer functi ons for convol uti onal code have onl y one format i n the
Communi cati ons Tool box. Thi s nonl i near for mat can be vi ewed as an i nput/
output mappi ng functi on that maps al l possi bl e i nputs and states to the
possi bl e outputs. The next four secti on di scuss the l i near and nonl i near
tr ansfer formats i n tur n.
3
Outport2
XOR
Logical
Operator2
XOR
Logical
Operator1
2
Outport1
Memory2
2
Inport1
1
Outport
XOR
Logical
Operator
Memory1 Memory
1
Inport
3 Tutorial
3-40
The Bina r y Form . The bi nary tr ansfer functi on matr i x t r ans _f unc i s a
K-by-N*(M+1) bi nar y matr i x. t r an_f unc can be wr i tten i n the fol l owi ng form:
where i s a l ength M+1 bi nary r ow vector , whi ch i s the transfer functi on
from i th i nput to jth output. The row vector r epresents an ascendi ng
order ed pol ynomi al . For exampl e the (3, 2, 2) convol uti onal code
can be r epresented by the bi nar y for m wi th the speci fi ed c ode _par am=[ 3 2 2]
and
The O cta l Form . The octal for m of the tr ansfer functi on matr i x gen has the for m:
i n whi ch i s the i th i nput to the jth output octal for m tr ansfer functi on. Note
that the bi nary form of the tr ansfer functi on i s i n ascendi ng or der. The octal
form i s a conversi on of the bi nar y vector al ong the ascendi ng di recti on. The
octal for m of the transfer functi on gen i s:
tr an_func
t
11
t
12
... t
1N
... ...
t
K1
t
K2
... t
KN
=
t
i j
t
i j
1 X
2
+ X X +
2
X
0 X 1
tr an_func
1 0 1 0 1 1 0 1 0
0 0 0 0 1 0 1 0 0
=
tr an_func
g
11
g
12
... g
1N
... ...
g
K1
g
K2
... g
KN
=
g
i j
gen
5 3 2
0 2 4
=
Error-C ontrol C oding
3-41
The Sta te-Spa ce Form. The state-space tr ansfer functi on i s repr esented i n a l i near
system for m. A l i near system can be wr i tten as a di fference equati on
where u(k) i s the i nput vector, x(k) i s the state, and y(k) i s the output vector .
Mul ti pl i cati on and addi ti on are bi nar y oper ati ons. Thi s functi on outputs the
tr ansfer functi on i n the form of
where V i s a col umn vector wi th i ts fi rst three el ement bei ng the output vector
l ength, the i nput l ength, and the state vector l ength. The l ast el ement of the
vector i s assi gned to be -I nf.
Usi ng the functi on s i m2t r an, the state space for m of the tr ansfer functi on can
be obtai ned by usi ng the command:
gen = s i m2t r an( f i g_10_9 )
gen =
Usi ng command gen2abc d, you can fi nd the [ A, B, C, D] state space matri ces
descr i bed i n the di ffer ence equati on defi ned i n thi s secti on.
N onlinea r Tra nsfer Functions for Convolutiona l Coding. A nonl i near system can be
wr i tten as the set of di fference equati ons
x k 1 + ( ) Ax k ( ) Bu k ( ) + =
y k ( ) Cx k ( ) Du k ( ) + =
gen
A
C
B
D
V
=
0 1 1 0 3
0 0 1 1 2
0 0 1 0 2
0 0 0 1 0
1 0 1 1 Inf
x k 1 + ( ) f x k ( ) u k ( ) , ( ) =
y k ( ) g x k ( ) u k ( ) , ( ) =
3 Tutorial
3-42
where u(k) i s the i nput vector , x(k) i s the state, and y(k) i s the output vector .
The str uctur e of the nonl i near tr ansfer functi on i s
where N i s the output vector l ength, K i s the i nput vector l ength, M i s the state
vector l ength, and U and V are i nput and output col umn vectors that have
l engths equal to 2
K+M
. The symbol I nf i n the fi r st row, fi rst col umn entr y
posi ti on i ndi cates that thi s transfer functi on i s i n the nonl i near format. The
r est of thi s secti on di scusses the str uctur e of the nonl i near for mat, and how i t
can be vi ewed as an i nput/output mappi ng functi on.
I n convol uti onal codi ng, the i nput si gnal s, state val ues, and outputs ar e bi nary.
Whi l e i t i s possi bl e to construct the nonl i near tr ansfer functi on i n bi nar y for m,
you can convert a l ength M bi nary state vector i nto an i nteger format. The
di scussi on that fol l ows assumes that the i nput, state, and output vector s have
been converted from bi nary to i nteger . I n convol uti onal codi ng, the r ange of
possi bl e i nputs, states, and outputs ar e fi ni te. After conver ti ng from bi nar y to
i nteger val ues, the possi bl e val ues for the states and the outputs are i n the
r ange [0 : 2
M
-1]. The possi bl e i nput val ues are i n the range [0 : 2
K
-1].
The col umn vector U contai ns the possi bl e i nput val ues of u(k). The matr i x that
r epr esents the nonl i near transfer functi on maps i nputs of gi ven val ues to the
r esul ti ng outputs:
The fi r st 2
M
el ements of V ar e the val ues of y(k) when u(k) = 0 and
x = [0 : 2
M
- 1].
The second 2
M
el ements of V ar e the val ues of y(k) when u(k) = 1 and
x = [0 : 2
M
- 1].
Thi s process conti nues unti l i t exhausts al l possi bl e i nput and state val ues.
The l ast 2
M
el ements of V ar e the val ues of y(k) when u(k) = 2
K
-1 and
x = [0 : 2
M
- 1].
Thi s i s a mappi ng of al l the possi bl e i nputs u(k) and states x(k) to the outputs
y(k). The nonl i near tr ansfer functi on can al so be vi ewed as a l ookup tabl e
whose l ookup var i abl es ar e the i nput and state val ues.
Note that the nonl i near transfer functi on constr ucted her e does not shar e the
mathemati cal pr oper ti es of l i near tr ansfer functi ons. For exampl e, none of the
Inf N
M K
U V
Error-C ontrol C oding
3-43
spectral theory of l i near transfer functi ons appl i es. One advantage of nonl i near
tr ansfer functi ons i s computati onal speed. Si nce no mathemati cal operati ons
occur other than the assi gnment of an output to gi ven i nput and state val ues,
the output i s i mmedi atel y avai l abl e.
For exampl e, you can constr uct a nonl i near transfer functi on based on the
Si mul i nk bl ock di agr am of (3, 2, 2) convol uti onal code di scussed i n the
Transfer Functi ons for Convol uti onal Code secti on of thi s chapter. For thi s to
wor k, r epl ace the Memory bl ocks by Uni t Del ay bl ocks i n the bl ock di agram
and save i t as nl c oncd. Use the s i m2t r an functi on to gener ate the nonl i near
tr ansfer functi on:
gen = s i m2t r an( ' nl conc d' )
gen =
The resul t i s the nonl i near tr ansfer functi on. For more i nformati on on
nonl i near transfer functi ons, refer to the entr y for s i m2t r an i n Chapter 5,
MATLAB Functi on Reference.
Inf 3
2 2
0 0
0 4
1 0
1 4
3 5
3 1
2 5
2 1
2 6
2 2
3 6
3 2
1 3
1 7
0 3
0 7
3 Tutorial
3-44
Convoluti ona l Encoding
You can perform convol uti onal encodi ng by usi ng the command conv enc o. I n
the encodi ng pr ocess, a convol uti onal code transfer functi on can be converted
i nto a di screte-ti me transfer functi on
i n whi ch u i s the l ength K i nput vector and y i s the l ength N output vector. The
matri ces A, B, C, and D are constant matri ces wi th al l el ements i n GF(2). The
number k i s an non-negati ve i nteger that speci fi es the computati on ti me. The
computati on assumes the i ni ti al state x(0) i s a zer o vector.
Convoluti ona l Decodi ng
Thi s tool box uses the Vi terbi method for decodi ng of convol uti onal codes. The
Vi ter bi al gor i thm i s a maxi mum l i kel i hood decodi ng pr ocedur e that takes
advantage of the fact that a convol uti onal encoder i s a fi ni te state devi ce. I f the
constr ai nt l ength, M, i s r el ati vel y smal l , i .e. M 8, the decoder can perform
opti mal decodi ng wi th r el ati vel y few computati ons.
The Vi terbi decoder perfor ms ei ther hard decision or soft decision decodi ng. A
hard deci si on decoder accepts bi t deci si ons from the demodul ator. These
deci si ons assi gn ei ther a 0 or 1 to each recei ved bi t. Soft deci si on decodi ng
i nvol ves usi ng demodul ator outputs that are proporti onal to the log likelihood
of the demodul ated bi t bei ng ei ther 0 or 1. The l og l i kel i hood i s the l ogari thm
of the probabi l i ty of a bi t bei ng, for exampl e, 0 i f the demodul ated bi t was 1. I f
the tr ansmi tted bi t i s var i abl e x and the demodul ated bi t i s var i abl e z, thi s
expr essi on i s the l og l i kel i hood that x i s 0 gi ven that z i s 1:
Soft deci si on decodi ng gener al l y pr oduces better perfor mance at the cost of
i ncr eased compl exi ty. The next two secti ons di scuss soft and hard deci si on
decodi ng i n tur n.
Soft Decision Decoding. For soft deci si on decodi ng, the r ecei ved codewor d can be
any real number. Because of channel fadi ng, noi se, i nter fer ence, and other
factors, a si gnal transmi tted as a 0, for exampl e, may be recei ved as some
nonzero r eal val ue x. From a priori knowl edge of the channel , you can esti mate
the pr obabi l i ti es of the val ue x fal l i ng i n certai n regi ons. A si mi l ar anal ysi s
x k 1 + ( ) Ax k ( ) Bu k ( ) + =
y k ( ) Cx k ( ) Du k ( ) + =
Error-C ontrol C oding
3-45
hol ds for the tr ansmi ssi on of a si gnal 1. Use the notati on P(r c v| ms g) to
repr esent the probabi l i ty of r ecei vi ng r c v data whi l e sendi ng ms g data. Usi ng
the defi ni ti on, we can descri be a transmi tti ng channel by a set of tr ansfer
probabi l i ti es. For i nstance, i n the fol l owi ng channel ,
the probabi l i ty of si gnal 0 bei ng recei ved i n r ange (-I nf, 1/10] equal s 2/5 or
P((-I nf, 1/10]| 0) = 2/5. The probabi l i ty of si gnal 1 bei ng recei ved i n r ange
(-I nf, 1/10] equal s 1/16 or P((-I nf, 1/10]| 1) = 1/16. Thi s tabl e pr esents the
probabi l i ty structure associ ated wi th the communi cati on channel :
Round br ackets i ndi cate an open range. Open r anges do not i ncl ude the
boundary poi nts. Squar e br ackets i ndi cate a cl osed r ange. Cl osed ranges
i ncl ude the boundary poi nts.
The opti mum path for a soft deci si on maxi mi zes the metr i c of the r ecei ved
si gnal r and the cor rected si gnal c. For a codeword l ength N tr ansmi ssi on, the
metric M(r| c) i s defi ned as
Receiving Probability
When Sending 0
Receiving Probability
When Sending 1
P((-I nf, 1/10]| 0) = 2/5 P((-I nf, 1/10]| 1) = 1/16
P((1/10, 1/2]| 0) = 1/3 P((1/10, 1/2]| 1) = 1/8
P((1/2, 9/10]| 0) = 1/5 P((1/2, 9/10]| 1) = 3/8
P((9/10, I nf)| 0) = 1/15 P((9/10, I nf)| 1) = 7/16.
0
1
(-Inf, 1/10]
(1/10, 1/2]
(1/2, 9/10]
(9/10, Inf)
2/5
1/3
1/5
1/15
1/16
1/8
3/8
7/16
M r c ( ) P r
i
c
i
( ) l og
i 1 =
N

=
3 Tutorial
3-46
where r
i
i s the i th el ement of the recei ved codewor d vector and c
i
i s the i th
el ement of the corr ected vector .
The MATLAB functi ons dec ode and v i t er bi and the Si mul i nk bl ocks Cycl i c
Decode Vector I n/Out and Cycl i c Decode Sequence I n/Out requi re that you
defi ne a transfer pr obabi l i ty vari abl e t r ans _pr ob, a three row matr i x. The fi r st
r ow of t r ans _pr ob i s the l ower boundar y of the recei ved range. The second row
i s the pr obabi l i ty of r ecei vi ng si gnal i n the r ange speci fi ed i n the fi rst row gi ven
that the transmi tter sent a 0 si gnal . The thi rd row i s the probabi l i ty of
r ecei vi ng si gnal i n the r ange i n the fi rst row gi ven that the transmi tter sent a
1 si gnal . The format i s:
Conti nui ng wi th the channel exampl e, the tr ansfer pr obabi l i ty i s:
Ha rd Decision Decoding. For har d deci si on decodi ng, the recei ved codewor ds are
bi nary data. The pr obabi l i ty of si gnal 0 bei ng r ecei ved as 0 i s q, or P(0| 0) = q;
P(1| 0) = 1-q. The pr obabi l i ty of si gnal 1 bei ng r ecei ved as 1 i s q, or P(1| 1) = q;
P(0| 1) = 1-q. Thi s tool box al ways assumes q>1/2. I n case q<1/2, you can si mpl y
r everse ones and zeros pr i or to the decodi ng pr ocess. The opti mum path i s the
one that has the mi ni mum Hammi ng di stance between the recei ved codeword
and the corr ected codeword (know as the survivor). The Hammi ng di stance
between two bi nar y vector s i s defi ned as the number of i ndi ces where the two
vectors do not match.
The Viterbi Algorithm. The Vi terbi al gor i thm i s good for both soft and har d
deci si on decodi ng. The cr i teri on used for deci si on maki ng i s the metr i c for soft
deci si on decodi ng and the Hammi ng di stance for har d deci si on decodi ng.
tr ans_prob
L B1 L B2
P L B1 L B2 [ , ] 0 P L B2 L B3 [ , ] 0
P L B1 L B2 [ , ] 0 P L B2 L B3 [ , ] 0
=
trans_prob

1
10
------
1
2
---
9
10
------
2
5
---
1
3
---
1
5
---
1
15
------
1
16
------
1
8
---
3
8
---
7
16
------
=
Error-C ontrol C oding
3-47
A step-by-step descr i pti on of the Vi ter bi al gor i thm i s:
1 Assi gn i ni ti al condi ti ons:
i = 0; the curr ent computati on i ndex.
j = 0; the cur rent deci si on i ndex.
x
1
(0) = 0; the i ni ti al state.
m
1
=0; the i ni ti al cri ter i on (metri c for soft deci si on decodi ng and Hammi ng
di stance for hard deci si on decodi ng).
2 Usi ng al l val i d x
b
(i ), compute al l possi bl e i nput paths to x
e
(i +1). I f there i s
mor e than one i nput path to x
e
(i +1), keep the one that i s opti mal under the
cri ter i on you are usi ng. Thi s i s the maxi mum metri c val ue, cal l ed the metric
accumulation, i n soft deci si on decodi ng and the mi ni mum
Hammi ng di stance i n har d deci si on decodi ng. Keep the i nput path l eadi ng
to x
e
(i +1) and the cri teri on val ue of that path. Note that b and e ar e possi bl e
number s between 1 and 2
length(x)
.
3 Traci ng fr om x
e
(i +1), remove al l paths that cannot reach step i +1.
4 For a l i mi ted memor y case, wher e you ar e eval uati ng paths of fi xed l ength
onl y, check i f the buffer i s ful l , i .e., i f i -j i s greater than the fi xed path l ength.
I f i t i s ful l , use the opti mal val ue cal cul ated under the cr i ter i on you ar e usi ng
to deci de whi ch state to keep and cl ear the memory space of path segments
that are no l onger bei ng used (thi s means you must set j=j+1). For an
unl i mi ted memory case, check i f the begi nni ng of the whol e path x(j) to
x(j+1) i s a si ngl e connecti on. I f i t i s, keep the path as the r esul t of the
deci si on. j=j+1.
5 I f i +1 i s not the encode of the codeword transfer , i =i +1, go to 2. Other wi se go
to 6.
6 Take x
e
(i +1)=0 as the fi nal state, trace back to j al l of the paths i n the
deci si on.
Thi s tool box provi des functi on conv enco for convol uti onal encodi ng. Functi on
vi t er bi i mpl ements the convol uti onal decode Vi ter bi al gori thm for both
l i mi ted memor y l ength and unl i mi ted memor y l ength.
3 Tutorial
3-48
A trellis i s the set of paths of the possi bl e tr ansi ti ons from one state to another.
You can vi ew the trel l i s usi ng vi t e r bi . I n trel l i s pl ots, the path wi th bol d l i nes
i s the deci si on path, whi ch i s al ways the opti mal path for the gi ven condi ti ons.
You can al so use functi ons encode and de code wi th opti on c onvol ut i on for
convol uti onal encode and decode cal cul ati ons. Convol uti onal encode/decode
Si mul i nk bl ocks ar e al so avai l abl e i n the Er ror-Control Code subl i br ary.
Ex a mple of Convoluti ona l Decoding
Thi s exampl e uses the (3, 3, 2) convol uti onal code di scussed on page 3-42 i n the
Tr ansfer Functi ons of Convol uti onal Code secti on of thi s chapter. You can
vi ew the bl ock di agram of the transfer functi on by typi ng:
t ut conmd
The fi gur e bel ow shows a bl ock di agram used for testi ng the convol uti onal code
wi th the (3, 3, 2) convol uti onal code transfer functi on:
Convol uti onal decodi ng uses the Vi terbi al gori thm. You can vi ew the tr el l i s
used i n the Vi ter bi decodi ng pr ocess whi l e r unni ng the si mul ati on by enter i ng
the tr el l i s l ength i n the Trellis figure plot length par ameter i n the
Vec to sca
converter
Berror Convl en
Sca to vec
converter
Error
meter
Rd wksp
Generate
tran_func
Convl de
Error-C ontrol C oding
3-49
Convol uti onal Decode bl ock i n the above di agram. Thi s fi gure shows the tr el l i s
used i n the computati on:
I n the tr el l i s pl ot, the l i nes ar e al l the possi bl e deci si on paths. The bol d l i nes
ar e the opti mal path, whi ch i s used as the decodi ng path. The numbers on the
ri ght-hand si de ar e the Hammi ng di stance i n the decodi ng. You can change the
0
1
0
1
1
0
1
0
State 0
State 4
State 2
State 6
State 1
State 5
State 3
State 7
Time
3 Tutorial
3-50
convol uti onal code transfer functi on by changi ng the Si mul i nk bl ock di agr am
for convol uti onal code str uctur e. For i nstance, you can change the structure to:
The si mul ati on wi th the changed bl ock di agram has a di ffer ent tr el l i s di agr am.
Ther e ar e now onl y four states i n the trel l i s pl ot i nstead of ei ght:
I f you know the transfer functi on you i ntend to use, you can di r ectl y use i t
i nstead of usi ng the bl ock di agram method. For exampl e, assume that the
i nfor mati on si gnal sequence i s i n vector ms g. I nstead of usi ng Si mul i nk bl ocks,
1
2
XOR
3
1
2
0
1
0
1
State 0
State 2
State 1
State 3
Time
Error-C ontrol C oding
3-51
gener ate the transfer functi on usi ng s i m2t r an and work di rectl y wi th i t. The
MATLAB code needed to run the encode and decode process usi ng the tr ansfer
functi on i s:
t r ans _f unc = s i m2t r an( ' t ut c onmd' ) ;
c ode_wor d = encode ( ms g, s i z e ( t r ans _f unc , 2) , . . .
s i z e( t r ans _f unc, 1) , ' c onvol ut i on' , t r ans _f unc ) ;
r ec ov er ed = de code ( ms g, s i z e ( t r ans _f unc , 2) , . . . .
s i z e( t r ans _f unc, 1) , ' c onvol ut i on' , t r ans _f unc ) ;
Refer to the entri es for encode and de code i n Chapter 5, MATLAB Functi on
Refer ence, for a mor e detai l ed di scussi on of how to use these functi ons.
3-52
3
Modulation and Demodulation
I n most medi a for communi cati on onl y a fi xed amount of the frequency
spectrum i s avai l abl e for transmi ssi on. Al though the si gnal to be tr ansmi tted
may have a r el ati vel y smal l bandwi dth, i ts frequency spectrum may not fal l
wi thi n the necessary frequency range. The usual sol uti on i s to modul ate the
i nput si gnal wi th a carr i er si nusoi d that i s wi thi n the desi r ed frequency range.
The r esul ti ng waveform wi l l be wi thi n the desi r ed frequency r ange and can be
tr ansmi tted. At the recei ver the wavefor m can be demodul ated to recover the
ori gi nal si gnal .
There ar e two major categor i es i n modul ati on/demodul ati on: analog and
digital. I n anal og modul ati on, the i nput message si gnal i s anal og. I n di gi tal
modul ati on, the i nput message si gnal i s di scr ete.
I n the si mul ati on of modul ati on techni ques, ther e ar e two opti ons for
repr esenti ng the modul ati on/demodul ati on process: passband and baseband.
I n passband si mul ati on, the car ri er si gnal i s i ncl uded i n the transmi ssi on
model . The fr equency of the carr i er si gnal i s usual l y much greater than the
hi ghest fr equency of the i nput message si gnal . By the Nyqui st sampl i ng
theor em, the si mul ati on sampl i ng fr equency must be at l east two ti mes l ar ger
than the car ri er si gnal fr equency to recover the message cor rectl y, but the
si mul ati on of a hi gh fr equency si gnal can be ver y sl ow and i neffi ci ent. To speed
up the si mul ati on process, a baseband si mul ati on i s commonl y used when the
par ameter sel ecti on and performance of the modul ati on and demodul ati on are
not the curr ent desi gn i ssue.
Baseband si mul ati on, al so known as the l ow-pass equi val ent method, uses the
complex envelope of a passband si gnal . The Baseband Anal og Demodul ati on
secti on of thi s chapter presents the mathemati cal defi ni ti on of a compl ex
envel ope; here i t i s i mpor tant to note that i t i s an i mpor tant tool i n baseband
modul ati on.
The secti ons bel ow di scuss passband anal og modul ati on/demodul ati on and
passband di gi tal modul ati on/demodul ati on i n tur n. Si nce the demodul ati on
techni ques used i n baseband si gni fi cantl y di ffer from the modul ati on
techni ques, thi s chapter di scusses each of these separatel y.
3-53
The secti ons under Modul ati on and Demodul ati on are:
Passband anal og modul ati on and demodul ati on
Passband di gi tal modul ati on and demodul ati on
Baseband modul ati on and demodul ati on
Baseband anal og modul ati on
Baseband anal og demodul ati on
Baseband di gi tal modul ati on
Baseband di gi tal demodul ati on
Passband Analog Modulation and Demodulation
There are a number of methods for anal og modul ati on: ampl i tude modul ati on
(AM), fr equency modul ati on (FM), and phase modul ati on (PM). The ampl i tude
modul ati on i ncl udes doubl e si deband suppressed car ri er (DSB-SC) AM, doubl e
si deband wi th tr ansmi ssi on car ri er (DSB-TC) AM, si ngl e si deband suppressed
carr i er (SSB) AM, and quadrature ampl i tude modul ati on (QAM).
The functi on amod i n thi s tool box i s desi gned for the anal og passband
modul ati on computati on, and the functi on ademod for the anal og passband
demodul ati on computati on. You can sel ect modul ati on/demodul ati on methods
by assi gni ng an i nput str i ng parameter met hod. The demodul ati on method
chosen must match the modul ati on method i n order to recover the message
si gnal . The tabl e bel ow l i sts the modul ati on methods avai l abl e:
Method Meaning
3-54
To use the functi on ademod and anal og demodul ati on bl ocks, you must desi gn
a l owpass fi l ter. The Si gnal Processi ng Tool box pr ovi des a vari ety of functi ons
for fi l ter desi gn, such as the functi ons but t er , c he by 1, cheby2, e l l i p, etc. Thi s
tool box r equi r es di screte-ti me fi l ter s i n the demodul ati on functi ons and bl ocks.
The al gor i thms i n the demodul ati on process r equi r e that the l owpass fi l ters
el i mi nate the car ri er si gnal . As a r ul e of thumb, you can defi ne the cut-off
frequency to be f
c
/ 2, hal f of the carr i er frequency. For exampl e, i f the
computati on sampl i ng fr equency i s Fs , you can use the functi on but t e r to
desi gn an Nth order Butterwor th l owpass fi l ter wi th cut-off frequency Fc:
[ num, de n] = but t er ( N, Fc /Fs ) ;
The vector outputs, num and de n, ar e the numer ator and the denomi nator of the
l owpass fi l ter transfer functi on.
The car ri er fr equency must be hi gher than the bandwi dth of the message
si gnal . The cut-off frequency l i mi ts the bandwi dth of the message si gnal . When
the cut-off frequency i s too hi gh, the car ri er fr equency may not be fi l ter ed out.
When the cut-off fr equency i s too l ow, i t can narr ow the bandwi dth of the
message si gnal .
Example of the Effect of Lowpass Filters on Demodulation
I n thi s exampl e, a sawtooth message si gnal i s modul ated by usi ng frequency Fc
wi th computati on sampl i ng fr equency Fs. The r esul ti ng si gnal i s demodul ated
amds b- s c Doubl e-si deband suppressed ampl i tude modul ati on
amds b- t c Doubl e-si deband wi th tr ansmi ssi on carr i er
ampl i tude modul ati on
ams s b Si ngl e-si deband suppr essed carr i er ampl i tude
modul ati on
f m Frequency modul ati on
pm Phase modul ati on
qam Quadr atur e ampl i tude modul ati on
3-55
by usi ng three di ffer ent cut-off frequency fi l ter s. The l owpass fi l ters ar e
desi gned by the command:
[ num, de n] = but t er ( 2, F) ;
where F i s the cut-off frequency i n the desi gn. I n the fi gur e bel ow, thr ee pl ots
show the effect of the di fferent l owpass fi l ter s:
I n each pl ot, the dotted curve i s the demodul ati on output. The l eft pl ot uses the
suggested cut-off frequency F = Fc/Fs. The mi ddl e pl ot uses a hi gher cutoff
frequency F = 4 Fc/Fs. The ri ght pl ot uses a l ower cut-off fr equency F = Fc/Fs/
4. The hi gher cut-off fr equency al l ows the carr i er si gnal to mi x i n wi th the
demodul ated si gnal , whi l e a l ower cut-off frequency si gni fi cantl y narr ows the
bandwi dth of the demodul ated si gnal . Both effects ar e undesi rabl e.
Di fferent demodul ati on methods have di fferent pr oper ti es; you may need to
test sever al fi l ters befor e fi ndi ng the best fi l ter for your appl i cati on. The order
of the fi l ter i s al so an i mpor tant i ssue. I n general , a hi gher-order fi l ter has
steeper rol l off characteri sti cs compared to a l ower-or der fi l ter. However ,
computati onal i ssues may ar i se when the or der i s too hi gh.
There i s i nvari abl y a ti me del ay between a demodul ated si gnal and the ori gi nal
recei ved si gnal . Both the fi l ter or der and the fi l ter parameter s di rectl y affect
the l ength of thi s del ay.
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
1.5
1
0.5
0
0.5
1
1.5
Time (second)
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
1.5
1
0.5
0
0.5
1
1.5
Time (second)
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
1.5
1
0.5
0
0.5
1
1.5
Time (second)
3-56
Double-Sideband Suppressed Carrier Amplitude
Modulation and Demodulation
The doubl e-si deband suppressed car ri er ampl i tude modul ati on (DSB-SC AM)
method modul ates a message si gnal m(t) usi ng the for mul a
where y(t) i s the modul ated si gnal , f
c
i s the carr i er frequency (Hertz), and
c
i s
the i ni ti al phase (rad).
The corr espondi ng demodul ati on method, DSB-SC ADM, r ecover s the message
si gnal m(t) from the recei ved modul ated si gnal y(t). The demodul ati on
procedure i s shown i n the bl ock di agr am bel ow:
Figure 3-2: DSB-SC ADM Block Diagram
Costas Loop Demodulation Method with DSB-SC ADM. The DSB-SC ADM
method requi res knowl edge of the modul ati on phase. I f the exact modul ati on
phase i s not known, you may use the Costas phase-l ocked l oop demodul ati on
method, whi ch recovers the phase fr om the r ecei ved si gnal . The method i s
shown i n thi s fi gur e.
Figure 3-3: Costas Phase-Locked Loop Demodulation Block Diagram
y t ( ) m t ( ) 2f
c
t
c
+ ( ) cos =
Lowpass
fi l ter
X
m(t)
y(t)
2 sin(2f
c
t+
c
)
Lowpass
fi l ter
X
m(t)
y(t)
X
Lowpass
fi l ter
Lowpass
fi l ter
X VCO
90
o
shift
3-57
I n the fi gure, VCO i s the vol tage control l ed osci l l ator. A di scussi on of vol tage
control l ed osci l l ati on i s provi ded i n the Uti l i ti es secti on of thi s chapter . I n the
Si mul i nk bl ock l i brary, you can di r ectl y use the DSB-SC ADM bl ock, whi ch
contai ns a Costas phase-l ocked l oop. I n functi on ade mod, append ' /cos t as ' to
the end of the me t hod vari abl e to use the Costas l oop demodul ati on method. For
exampl e, i f the modul ated si gnal i s stor ed i n the vari abl e moded, the
demodul ati on pr ocess can be
r ec ov er ed = ademod( mode d, Fc , Fs , ' amds b- s c ' , i ni t i al _phas e )
or, usi ng the Costas l oop method:
r ec ov er ed = ademod( mode d, Fc , Fs , ' amds b- s c /c os t as ' )
Double-Sideband with Transmission Carrier Amplitude
Modulation and Demodulation
The doubl e-si deband wi th transmi ssi on carr i er ampl i tude modul ati on
(DSB-TC AM) i s a cl assi cal textbook method. Thi s method i s not used i n
practi ce because i t i s i neffi ci ent compar ed wi th other modul ati on methods i n
terms of energy costs. Thi s method i s very si mpl e, however , and i s commonl y
i ntroduced i n standar d communi cati ons textbooks.
DSB-TC AM modul ates a message si gnal m(t) usi ng the for m:
where y(t) i s the modul ated si gnal , f
c
i s the carr i er frequency (Her tz), and
c
i s
the i ni ti al phase (r ad). offset i s the offset for the ampl i tude of the i nput si gnal .
Thi s fi gure compar es DSB-SC AM and DSB-TC AM outputs:
y t ( ) m t ( ) offset + ( ) 2f
c
t
c
+ ( ) cos =
3-58
Figure 3-4: Comparison of DSB-SC AM and DSB-TC AM
I n the fi gure, the upper l eft pl ot i s the message si gnal ,. The upper ri ght pl ot i s
the DSB-SC AM modul ated si gnal . On the bottom l eft i s the message si gnal
after shi fti ng, and on the bottom ri ght i s the DSB-TC AM modul ated si gnal .
The rel ati onshi ps between the fi gur es are shown by the arr ows and the
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
1
0.8
0.6
0.4
0.2
0
0.2
0.4
0.6
0.8
1
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
1
0.8
0.6
0.4
0.2
0
0.2
0.4
0.6
0.8
1
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
2
1.5
1
0.5
0
0.5
1
1.5
2
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
2
1.5
1
0.5
0
0.5
1
1.5
2
modul ati on
DSB-SC AM
offset
modul ati on
DSB-SC AM
modul ati on
DSB-TC AM
3-59
accompanyi ng text. The command l i nes used i n prepar i ng the data to generate
the above fi gures are:
% Comput at i on t i me ; s ampl e r at e 100 Hz . Car r i e r f r e quency 10 Hz .
Fs = 100; t = [ 0: 200] /Fs ; Fc = 10;
% Mes s age s i gnal i s a 1 Hz s i n; dat a f or t he uppe r - l e f t pl ot .
x 1 = s i n( 2pi t ) ;
% Modul at ed s i gnal ; dat a f or t he upper - r i ght pl ot .
% Modul at i on c ar r i er f r eque nc y: 10 Hz .
y 1 = amod( x 1, Fc, Fs , ' amds b- s c' ) ;
% Mes s age s i gnal wi t h of f s e t ; dat a f or t he l ef t - bot t om pl ot .
x 2 = x1+1;
% DSB- SC AM modul at e s x 2; dat a f or t he r i ght - bot t om pl ot .
y 2 = amod( x 2, Fc, Fs , ' amds b- s c' ) ;
% DSB- TC AM modul at e s x 1; dat a f or t he r i ght - bot t om pl ot .
y 3 = amod( x 1, Fc, Fs , ' amds b- t c' , 1) ;
The corr espondi ng demodul ati on method, DSB-TC ADM, recover s the message
si gnal m(t) from the recei ved modul ati on si gnal y(t). The demodul ati on method
i s si mpl y an edge detecti on pr ocess, whi ch can be done by usi ng a l owpass fi l ter.
I n thi s tool box the demodul ati on of a DSB-TC AM modul ated si gnal uses the
same al gor i thm as i n the DSB-SC AM demodul ati on. The of f s e t i s subtr acted
after the DSB-SC ADM demodul ati on.
3-60
Single-Sideband Suppressed Carrier Amplitude
Modulation and Demodulation
I t i s i nstructi ve to anal yze the spectr um of si gnal y 1 i n the exampl e provi ded
i n the DSB-TC AM di scussi on. The fi gure bel ow compares the spectrums of the
DSB-TC AM modul ated si gnal and the same si gnal modul ated by SSB-TC AM:
The message si gnal i s a 1 Hz si nusoi dal si gnal and the carr i er si gnal Fc i s a
10Hz si nusoi dal si gnal . The spectr um i n the l eft pl ot has twi n peaks, whi ch are
the l ower and the upper si debands of the modul ated si gnal . The two si debands
ar e symmetr i cal wi th respect to the 10 Hz carr i er frequency, Fc. The spectr um
of a DSB-SC AM modul ated si gnal i s twi ce as wi de as the i nput si gnal
bandwi dth. To sol ve thi s probl em, you can use a si ngl e-si deband suppressed
carr i er ampl i tude modul ati on (SSB AM) techni que. SSB AM transmi ts ei ther
the l ower si deband or the upper si deband si gnal . The r i ght pl ot i s the SSB AM
modul ated si gnal . You can gener ate the data for the SSB AM modul ated si gnal
usi ng the command
y 4 = amod( x1, Fc, Fs , ' ams s b' )
and gener ate a spectrum anal ysi s by the commands (repl aci ng y by y 1 and y 4):
z = f f t ( y ) ;
z = abs ( z ( 1: l e ngt h( z ) /2+1) ) ;
f r q = [ 0: l engt h( z z ) - 1] Fs /l e ngt h( z ) /2;
pl ot ( f r q, z ) ;
You can al so use the Si mul i nk bl ocks to do the anal ysi s.
0 5 10 15 20 25 30 35 40 45 50
0
10
20
30
40
50
60
Frequency (Hz)
0 5 10 15 20 25 30 35 40 45 50
0
10
20
30
40
50
60
70
80
90
100
Frequency (Hz)
3-61
SSB AM uses a Hi l bert tr ansfor m fi l ter i n the modul ati on process. The method
i s shown i n the bl ock di agr am bel ow:
Figure 3-5: SSB AM Block Diagram
The car ri er source i s a si nusoi dal si gnal at a gi ven car ri er frequency. The
Hi l bert tr ansfor m fi l ter has the tr ansfer functi on
whi ch has the i mpul se r esponse:
The Hi l ber t tr ansfor m fi l ter outputs a -90
o
phase shi fted si gnal . The modul ated
si gnal i s a l ower si deband SSB versi on i f the si gn at the summati on bl ock i s
posi ti ve and an upper si deband SSB ver si on i f the si gn at the summati on bl ock
i s negati ve. The tool box provi des MATLAB commands hi l bat f , hi l bi i r , and
hi l bana for the Hi l bert tr ansfer fi l ter desi gn. Pl ease r efer to the
Transmi tti ng and Recei vi ng Fi l ters secti on i n thi s chapter for a di scussi on of
the al gor i thms of the Hi l bert tr ansfor m fi l ter i mpl ementati on.
The corr espondi ng demodul ati on method, SSB-ADM, i s the same as the
method descr i bed i n the fi r st fi gure of the DSB-SC ADM demodul ati on.
A l i mi tati on of the SSB AM method i s that you cannot use i t to tr ansmi t a
si gnal wi th a DC component.
carrier
source
Hilbert
transform
filter
-90
o
shift
X
X
+
+
-
+
H f ( ) j f ( ) sgn =
h t ( )
1
t
----- =
3-62
Quadrature Amplitude Modulation and Demodulation
The quadr ature mul ti pl ex doubl e-si deband ampl i tude modul ati on (QAM)
modul ates an i n-phase si gnal m
I
(t) and a quadr atur e si gnal m
Q
(t) usi ng the
formul a
where y(t) i s the modul ated si gnal , f
c
i s the carr i er frequency (Hertz), and
c
i s
the i ni ti al phase (r ad). Because the si ne and cosi ne si gnal s are or thogonal , the
ori gi nal si gnal s can be recovered l ater usi ng demodul ati on techni ques.
The pi cture bel ow descr i bes the QAM method:
Figure 3-6: QAM Block Diagram
The corr espondi ng demodul ati on method, QADM, recover s both the i n-phase
and quadrature si gnal s, m
I
(t) and m
Q
(t) r especti vel y, fr om the modul ated
si gnal y(t). The demodul ati on pr ocedur e i s shown i n the bl ock di agram bel ow:
Figure 3-7: QADM Block Diagram
y t ( ) m
I
t ( ) 2f
c
t
c
+ ( ) cos m
Q
t ( ) 2f
c
t
c
+ ( ) si n + =
90
o
shift
m
I
(t)
m
Q
(t)
X
X
cos(2

fct+

c)
+
y(t)
90
o
shift
lowpass
filter
lowpass
filter
y(t)
m
I
(t)
m
Q
(t)
cos(2

fct+

c)
X
X
3-63
MATLAB QAM Example . Unl i ke the other formats i n the amod and ademod
functi ons, QAM requi res that the message si gnal i nput be a matr i x wi th an
even number of col umns. Each consecuti ve pai r of col umns ar e the i n-phase
and quadrature components of the i nput si gnal . The odd numbered col umns
ar e the i n-phase si gnal components and the even numbered col umns are the
quadrature si gnal components. The code bel ow per for ms a QAM modul ati on/
demodul ati on on a set of si nusoi dal i nput si gnal s:
% The c omput at i on s ampl i ng f r eque nc y i s 100 Hz .
Fs = 100;
% The c ar r i e r f r eque nc y i s 15 Hz .
Fc = 15;
% The t i me v ec t or .
t = [ 0: 200] /100;
% Si gnal i s a f our c ol umn mat r i x.
% Eac h col umn i s a s i nus oi dal s i gnal , t he f r equenci es
% of whi c h ar e 1 Hz , 1. 5 Hz , 2 Hz , 2. 5 Hz r e s pe ct i v el y.
x = s i n( [ 2*pi *t ' , 3*pi *t ' , 4*pi *t ' , 5*pi *t ' ] ) ;
% Us e amod t o modul at e t he s i gnal wi t h c ar r i er f r eque nc y 15 Hz .
y = amod( x, Fc Fs , ' qam' ) ;
% The demodul at i on pr oc es s .
z = ade mod( y , Fc, Fs , ' qam' ) ;
% Pl ot t he demodul at ed s i gnal wi t h v er t i cal s hi f t i ng.
pl ot ( t , [ x ( : , 1) , x ( : , 2) , x ( : , 3) , x( : , 4) ] , . . .
t , [ z ( : , 1) , z ( : , 2) , z ( : , 3) , z ( : , 4) ] , ' - - ' ) ;
3-64
The command pl ot gener ates thi s fi gur e:
I n the pl ot, the sol i d curves ar e the ori gi nal si gnal s. The dashed cur ves ar e the
demodul ated si gnal s. There i s a ti me shi ft between the ori gi nal si gnal curves
and the cur ves recover ed by demodul ati on. Thi s ti me l ag i s caused by the
l owpass fi l ters used i n the demodul ati on pr ocess i n the si mul ati on.
Simulink QAM Example. Thi s exampl e compares the source si gnal to the
recovered si gnal after the QAM modul ati on/demodul ati on pr ocess. You can r un
thi s exampl e by typi ng t ut qam on the command l i ne:
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
2
1
0
1
2
3
4
5
6
7
8
3-65
The two si gnal generator s on the l eft generate 1 and 2 Hertz si nusoi dal si gnal s
respecti vel y. After two seconds of si mul ati on ti me, the pl ot from the scope
shows the curve i n the fi gure bel ow:
The l owpass fi l ter s i n the demodul ati on cause the ti me shi ft of the
demodul ated si gnal s shown by the dashed cur ves.
Frequency Modulation and Demodulation
The fr equency modul ati on (FM) modul ates a message si gnal m(t) by var yi ng
the frequency of the output si gnal y(t) as a functi on of the ampl i tude of the
i nput si gnal . The formul a for the modul ated si gnal i s
QM
DSBSC
AM
QM
DSBSC
ADM
Mux
+
+
Mux
2
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
1.5
1
0.5
0
0.5
1
1.5
2
2.5
3
3.5
Time (second)
y t ( ) 2f
c
t 2 t ( )
c
+ + ( ) cos =
3-66
where y(t) i s the modul ated si gnal , f
c
i s the carr i er frequency (Hertz), and
c
i s
the i ni ti al phase (rad). (t) i s the modul ati on phase, whi ch changes wi th the
ampl i tude of the i nput m(t). The for mul a for (t) i s
where k
c
i s the sensitivity factor, whi ch i s a gai n on the i ntegrator output. The
FM functi onal i ty i s al so known as a vol tage contr ol l ed osci l l ator (VCO). The
ampl i tude of the i nput si gnal vol tage control s the osci l l ati on fr equency of the
output si gnal . The demodul ati on pr ocess for a FM modul ated si gnal uses a
phase-l ocked l oop method:
Figure 3-8: FM Demodulation Block Diagram
The feedback l oop i s known as a phase-l ocked l oop, whi ch recovers the cor rect
phase fr om the recei ved si gnal . The frequency demodul ati on uses a mul ti pl i er
phase detector. The FM method i mpl emented i n thi s tool box i s a nar row band
FM, whi ch as i ts name i mpl i es, r estr i cts the fr equency modul ati on to a fi xed
bandwi dth. For the di ffer ences between narr ow and wi deband FM, refer to
Hambl ey.
Phase Modulation and Demodulation
Li ke FM, the phase modul ati on (PM) method i s an angl e modul ati on method.
The ampl i tude of the i nput si gnal m(t) di rectl y affects the phase of the output
si gnal y(t) i n the PM modul ati on process. The for mul a of the modul ated si gnal
i s
t ( ) k
c
m t ( )dt
0
t

=
Lowpass
fi l ter
m(t)
y(t)
VCO
Phase
detector
y t ( ) 2f
c
t 2 t ( )
c
+ + ( ) cos =
3-67
where y(t) i s the modul ated si gnal , f
c
i s the carr i er frequency (Her tz), and
c
i s
the i ni ti al phase (rad). (t) i s the modul ati on phase, whi ch changes wi th the
ampl i tude of the i nput m(t). The for mul a for the change i n phase i s
where k
c
i s the sensi ti vi ty factor . The PM demodul ati on uses the same
phase-l ocked l oop as that i n the FM demodul ati on, but adds an i ntegrator to
the system after the PLL l oop:
Figure 3-9: PM Demodulation Block Diagram
I n the bl ock di agr am, 1/s i ndi cates an i ntegrator.
You can choose to use me t hod=' pm' i n the amod and ademod commands for PM
and i ts demodul ati on, or use the PM and PDM bl ocks i n the modul ati on bl ock
subl i br ary for Si mul i nk si mul ati on.
Passband Digital Modulation and Demodulation
Thi s secti on di scusses passband di gi tal modul ati on and demodul ati on
methods. The modul ati on/demodul ati on techni ques di scussed i n the anal og
modul ati on/demodul ati on secti on of thi s chapter are rel evant to the di scussi on
of di gi tal methods. Pl ease read thr ough the Passband Anal og Modul ati on and
Demodul ati on secti on to understand ful l y the di scussi on here.
Di gi tal modul ati on i ncl udes two parts: di gi tal to anal og mappi ng and anal og
modul ati on. Di gi tal to anal og mappi ng techni ques conver t the r ecei ved di gi tal
data i nto anal og si gnal s. Anal og modul ati on then modul ates the mapped
t ( ) k
c
m t ( ) =
Lowpass
fi l ter
m(t) y(t)
VCO
Phase
detector
1
s
3-68
si gnal s. The di agr am bel ow shows how di gi tal modul ati on di vi des i nto a
di gi tal -to-anal og mappi ng and an anal og modul ati on:
Di gi tal to anal og mappi ng i nvol ves several key concepts. Typi cal l y, di gi tal
si gnal s form a fi ni te set of symbol s. For exampl e, i n bi nar y transmi ssi on i t i s
possi bl e to consi der pai rs of bi nar y numbers as symbol s. I n thi s case, the
symbol set i s 00, 01, 10, and 11, maki ng four di sti nct symbol s. A di gi tal
mappi ng al gor i thm must have at l east four mappi ng poi nts to map the symbol s
uni quel y. The number of poi nts i n the si gnal set i s cal l ed the M-ary number i n
thi s tool box. I n the communi cati ons fi el d, the M-ary number i s al so known as
the al phabet si ze. A good choi ce i n thi s exampl e for the M-ar y number i s four.
The mappi ng al gori thm must assi gn a di ffer ent set of anal og si gnal s for each
mappi ng poi nt; her e a good choi ce mi ght be si n(f
c
2t) + cos(f
c
2t) for 00,
si n(f
c
2t) - cos(f
c
2t) for 01, and so on unti l the four possi bl e mappi ng poi nts
ar e used. The ar rangement of the si gnal set i n the signal space, the space that
di gi tal mappi ng al gor i thm uses to map the mappi ng poi nts, i s cal l ed the
constellation. The pi cture bel ow shows the si gnal space of the mappi ng just
descr i bed:
Figure 3-10: QAM Signal Space
Di gi tal
modul ati on
message
si gnal
modul ated
si gnal
Di gi tal
mappi ng
Anal og
modul ati on
Equi val ent
modul ated
si gnal
message
si gnal
Amplitude of
sin(f
c
2t)
Amplitude
of cos(f
c
2t)
1
-1
1 -1
3-69
Thi s depi cts a 4-ar y square constel l ati on for the di gi tal mappi ng associ ated
wi th quadr ature ampl i tude modul ati on (QAM).
I n gener al , di gi tal demodul ati on i s the i nverse of the modul ati on process. A
modul ated si gnal i s demodul ated and then demapped from an anal og si gnal to
a di gi tal si gnal . The di agram bel ow shows how di gi tal demodul ati on di vi des
i nto an anal og demodul ati on and an anal og to di gi tal demappi ng:
Thi s demodul ati on structure appl i es to al l di gi tal demodul ati on methods
except for mul ti pl e fr equency shi ft keyi ng (M-FSK) and mul ti pl e phase shi ft
keyi ng (M-PSK). These methods use corr el ati on techni ques.
Types of Digital Modulation/ Demodulation
I n the si mul ati on of anal og modul ati on, two di fferent frequenci es ar e i nvol ved:
the carr i er frequency (f
c
) and the si mul ati on sampl i ng fr equency (f
s
). I n di gi tal
modul ati on, there i s one more frequency, the baud r ate (f
d
). To recover the
message si gnal from the demodul ati on si de corr ectl y, the rel ati onshi p between
the three fr equenci es must be f
s
>f
c
>f
d
.
The Si mul i nk bl ock l i brar y provi des a di gi tal modul ati on/demodul ati on
subl i br ary. The bl ocks i n thi s subl i brar y combi ne mappi ng and modul ati on
functi onal i ty i n each bl ock. The subl i br ary al so combi nes the cor respondi ng
demodul ati on and demappi ng techni ques. These combi ned bl ocks ar e for your
conveni ence. The Communi cati ons Tool box al so pr ovi des separate
di gi tal modul ati on/demodul ati on and mappi ng/demappi ng subl i brar i es. These
subl i br ari es separ ate the di gi tal mappi ng/demappi ng bl ocks and anal og
modul ati on/demodul ati on bl ocks. Thi s al l ows you di r ect access to al l aspects of
mappi ng/demappi ng and modul ati on/demodul ati on functi onal i ty.
Di gi tal
demodul ati on
Di gi tal
demappi ng
Anal og
demodul ati on
Equi val ent
modul ated
si gnal
message
si gnal
recovered
message
si gnal
recovered
modul ated
si gnal
3-70
I n the MATLAB functi on l i br ar y, the functi on dmod suppor ts di gi tal modul ati on.
The corr espondi ng di gi tal demodul ati on i s the functi on dde mod. The str i ng
var i abl e met hod i s a parameter i n both functi ons. You can use met hod to speci fy
the modul ati on and demodul ati on techni ques used i n the modul ati on/
demodul ati on pr ocess. When the str i ng ' /nomap' i s appended to the met hod
str i ng, the functi ons process the modul ati on and demodul ati on computati ons
onl y, suppr essi ng the mappi ng and demappi ng processes. You can then do
mappi ng and demappi ng separ atel y fr om the di gi tal modul ati on/demodul ati on
by usi ng the functi ons modmap and de modmap, r especti vel y.
Thi s tabl e l i sts the avai l abl e str i ngs for the met hod par ameter and thei r
meani ngs (for use wi th the functi ons dmod, ddemod, modmap, and de modmap):
Thi s tool box provi des i ndi vi dual bl ocks i n the Si mul i nk bl ock l i brary for the
same functi onal i ty.
The rest of thi s secti on di scusses each of the modul ati on methods i n the tabl e,
except for s ampl e , whi ch i s a uti l i ty that supports the modul ati on methods. The
di scussi on topi cs ar e di vi ded i nto mul ti pl e ampl i tude shi ft keyi ng (M-ASK),
Method Meaning
as k M-ar y ampl i tude shi ft-keyi ng modul ati on
qas k M-ar y quadrature shi ft-keyi ng modul ati on wi th squar e
constel l ati on
qas k/ci r M-ar y quadrature shi ft-keyi ng modul ati on wi th ci rcl e
constel l ati on
qas k/ar b M-ar y quadrature shi ft-keyi ng modul ati on wi th ar bi tr ar y
constel l ati on
f m Fr equency shi ft-keyi ng modul ati on (coher ent
demodul ati on)
f m/nonc oh Fr equency shi ft-keyi ng non-coher ent demodul ati on
pm Phase shi ft-keyi ng modul ati on
s ampl e A uti l i ty that supports modul ati on functi ons. s ampl e
perfor ms up- or down-sampl i ng the i nput si gnal .
3-71
quadrature ampl i tude shi ft keyi ng (QASK), mul ti pl e fr equency shi ft keyi ng
(M-FSK), and mul ti pl e phase shi ft keyi ng (M-PSK).
M-ary Amplitude Shift-Keying Modulation
M-ar y ampl i tude shi ft-keyi ng (M-ASK) modul ati on i ncl udes two parts: M-ASK
mappi ng fol l owed by anal og ampl i tude modul ati on. M-ASK mappi ng i s a one
di mensi onal codi ng pr ocess that maps the i nput di gi tal symbol s i nto real
numbers i n the i nterval [-x, x], where x i s the speci fi ed maxi mum number. The
i nput symbol s ar e i nteger s i n the range [0, M-1], where M i s the M-ary number .
The outputs are si gnal s wi th maxi mum ampl i tudes equal to assi gned val ues
between [-x, x]. The fol l owi ng fi gure depi cts the constel l ati on of M-ASK
mappi ng for the M-ary numbers 2, 4, 8, and 16:
Figure 3-11: 2, 4, 8, and 16 Constellation M-ASK Mapping
Thi s tool box sets the M-ASK maxi mum val ue x equal to 1. I n the fi gure, the
ci r cl es al ong the l i nes ar e the mappi ng poi nts. The number M must equal 2
K
,
where K i s a posi ti ve i nteger . You can vi ew the M-ASK constel l ati on pl ot by
usi ng the command:
modmap( ' as k' , M)
The Communi cati ons Tool box gi ves you the opti on to do the mappi ng and
modul ati on separ atel y. You can do the mappi ng process by usi ng the MATLAB
functi on modmap or the Si mul i nk MASK Map bl ock. You can use the output
from the mappi ng process as the i nput si gnal to the anal og modul ati on functi on
or bl ock. For anal og modul ati on, you can use the MATLAB functi on amod or the
Si mul i nk DSB SC-AM bl ock l ocated i n the Passband Di gi tal
Modul ati on/Demodul ati on subl i brary. The methods for the modul ati on and
demodul ati on pr ocesses must match to r ecover the si gnal cor rectl y.
M=2
M=4
M=8
M=16
0
x -x
3-72
You can do the mappi ng and modul ati on together i n thi s tool box. The MATLAB
functi on dmod computes both the mappi ng pr ocess and anal og modul ati on
process. The anal og modul ati on method used i n the functi on i s the DSB-SC AM
method. I n Si mul i nk you can use the MASK Mod bl ock to perform both
functi ons.
Demodul ati on i s the i nver se pr ocess of modul ati on. The demodul ati on pr ocess
i ncl udes the di gi tal demodul ati on and demappi ng. You can use ei ther the
MATLAB functi on demod or the Si mul i nk MASK Demod bl ock to si mul ate the
di gi tal demodul ati on and demappi ng together.
You can do the demodul ati on and demappi ng pr ocesses separatel y by usi ng the
MATLAB functi ons ddemod wi th the ' /nomap' opti on and demodmap. I n
Si mul i nk, use the DSB SC ADM and MASK Demap bl ocks for demodul ati on
and demappi ng r especti vel y.
MATLAB M-ASK Example . Thi s exampl e demonstr ates the M-ASK
modul ati on and demodul ati on MATLAB functi ons:
% As s i gn M- ar y numbe r M and c al cul at i on dat a l e ngt h N.
M = 16; N = 200;
% As s i gn di gi t al t r ans f e r f r eque ncy Fd, Car r i e r f r eque nc y Fc , and
% c omput at i on s ampl i ng f r eque nc y Fs .
Fd = 1; Fc = 10; Fs = 100;
% The mes s age s our ce
x = r andi nt ( N, 1, M) ;
% Di gi t al t o anal og s i gnal mappi ng.
mp = modmap( x, Fd, Fs , ' as k' , M) ;
% Modul at i on
y 1 = dmod( mp, Fc, Fd, Fs , ' as k/nomap' , M) ;
% Modul at i on wi t h mappi ng
y 2 = dmod( x, Fc , Fd, Fs , ' as k' , M) ;
% y 1 and y 2 ar e i dent i c al .
% Demodul at i on
z = dde mod( y 1, Fc , Fd, Fs , ' as k' , M) ;
% Er r or r at e
e r r = s yme r r ( x , z )
e r r =
0
3-73
Simulink M-ASK Example. Thi s exampl e uses the M-ASK Mod and Demod
bl ocks l ocated i n the Di gi tal Modul ati on/Demodul ati on subl i br ar y to bui l d a
si mpl e di gi tal modul ati on/demodul ati on exampl e. The fi gure bel ow depi cts the
bl ock di agr am structur e of the M-ASK mod/demod exampl e:
The Sampl ed Read Vari abl e bl ock generates the i nput message si gnal . The
Err or Rate Meter bl ock compar es the or i gi nal message to the recover ed
message. The M-ASK Mod and M-ASK Demod bl ocks si mul ate the modul ati on
and demodul ati on pr ocess. The M-ASK mod bl ock i s a masked bl ock, whi ch
contai ns the M-ASK map bl ock and DSB-SC AM bl ock. The M-ASK Demod
bl ock i s al so a masked bl ock, whi ch contai ns the Costas PL DSB ADM bl ock
and the M-ASK Demap bl ock.
M-ary Quadrature Shift-Keying Modulation
The M-QASK method i s the most commonl y used di gi tal modul ati on method i n
communi cati on systems. I n general , an M-QASK process takes the i nput
di gi tal symbol and maps i t i nto two i ndependent components: i n-phase and
quadrature. An anal og QAM method i s used to modul ate the i n-phase and
quadrature si gnal s. On the r ecei vi ng si de, the si gnal i s demodul ated i nto
i n-phase and quadr ature si gnal s. A demappi ng pr ocess recovers the message
si gnal by usi ng the i n-phase and quadrature si gnal s.
There are many mappi ng schemes avai l abl e to map the i nput symbol to the
i n-phase and quadrature components. Thi s tool box provi des three schemes for
M-QASK constel l ati ons: squar e, ci r cl e, and user -defi ned ar bi trary
constel l ati ons. Thi s secti on di scusses each i n tur n.
Sampled
read
variable
MASK
demod
Error Rate
Meter
MASK
mod
DSBSC
AM
MASK
map
1 1 1
Costas PL
DSB ADM
MASK
demap
1
3-74
Square Constellation
QASK wi th squar e constel l ati on has a symmetri c square constel l ati on
str ucture. The key vari abl e i n the square constel l ati on i s the M-ar y number , M.
I n thi s tool box, the squar e constel l ati on i s l i mi ted to be the resul t of power of
2, i .e. M=2
K
, wher e K i s a posi ti ve i nteger. Use the command
modmap( ' qas k' , M)
to pl ot a square constel l ati on fi gur e. The fi gur e bel ow i s the constel l ati on for
M=64 generated by usi ng the command modmap:
The resul t of the mapped data i s i n the i nterval [-x, x] for the i n-phase
component and [-y, y] for the quadr atur e component. The maxi mum val ue for
the i n-phase component x and the maxi mum val ue for the quadratur e
component y are l i sted i n thi s tabl e.
M-ary number
(M)
Maximum In-phase
(x)
Maximum Quadrature
(y)
2 1 1
4 1 1
8 3 1
16 3 3
64 7 7
QASK Constellation
3-75
Circle Constellation
The Ci rcl e constel l ati on i s defi ned by speci fyi ng the i n-phase and quadr atur e
components of each poi nt on each ci r cl e. The ci rcl e constel l ati on uses three
vectors to defi ne the constel l ati on: number of symbol s i n each ci r cl e (ni c); radi i
for each ci rcl e (r i c); and phase shi ft for each ci r cl e (pi c ). The thr ee vector s have
the same l ength. You can use ei ther
dmod( ' qas k/c i r ' , ni c, r i c , pi c )
or
modmap( ' qas k/c i r ' , ni c, r i c , pi c )
to pl ot the constel l ati on.
The thr ee var i abl es ni c , r i c , and pi c defi ne the constel l ati on poi nts on the
(concentr i c) ci rcl es. ni c defi nes the number of poi nts on each of the ci rcl es, r i c
defi nes the r adi i of each of the ci r cl es, and pi c defi nes the phase of ever y poi nt
on the ci r cl es. Al l thr ee par ameters ar e of equal l ength, and that l ength
speci fi es the total number of ci r cl es i n the constel l ati on. On a gi ven kth ci r cl e,
ther e ar e ni c ( k) poi nts, whi ch di str i bute evenl y on the ci rcl e. r i c ( k) defi nes
the radi us of the ci rcl e, and pi c ( k) speci fi es the phase val ue of each poi nt on
the ci rcl e i n r adi ans.
Circle Constellation Example. The fol l owi ng exampl e uses the functi on modmap
to generate constel l ati on pl ots:
% Lef t pl ot - a one ci r cl e cons t e l l at i on wi t h r adi us one.
modmap( ' qas k/c i r ' , 8, 1, 0)
% Mi ddl e pl ot - a t wo c i r cl e cons t e l l at i on whe r e
% e ac h ci r c l e has 8 poi nt s .
modmap( ' qas k/c i r ' , [ 8 8] , [ . 63 1] , [ pi /8 0] )
128 11 11
256 15 15
M-ary number
(M)
Maximum In-phase
(x)
Maximum Quadrature
(y)
3-76
A square constel l ati on can be pr oduced usi ng the ci rcl e constel l ati on for mat.
The fol l owi ng l i nes gener ate a squar e constel l ati on that i s the same as the
constel l ati on gi ven i n the squar e constel l ati on exampl e:
% Ri ght pl ot - a s quar e c ons t el l at i on us i ng t he c i r cl e f or mat .
r i c = s qr t ( [ 2 10 10 18 26 26 34 34] ) ;
modmap( ' qas k/c i r ' , 4*one s ( 1, 8) , x , as i n( [ 1 1 3 3 1 5 3 5] . /r i c) ) ;
These pl ots depi ct the thr ee constel l ati ons gener ated by the above code:
The l eft pl ot i s si mpl y a 8-PSK ci r cl e constel l ati on. The mi ddl e pl ot i s known as
the opti mal M-ary number 16 ci rcl e constel l ati on. The ri ght pl ot i s a 32-square
constel l ati on. The x-axes i n the pl ots are the i n-phase components, and the
y-axes are the quadrature components. The aster i sks are the constel l ati on
poi nts. The rectangul ar gr i d l i nes i n the ri ght pl ot have been added arti fi ci al l y
to show the r ectangul ar str uctur e.
The el ements i n the vectors ni c and r i c must be posi ti ve. The mappi ng fr om
the i nput i nteger to the components of the two axes must be one-to-one; the
al gor i thm does not al l ow repeati ng poi nts.
Arbitrary Constellation
The QASK wi th the user-defi ned arbi trar y constel l ati on has no l i mi tati on on
the shape of the constel l ati on structure, but the mappi ng must be one-to-one.
You can defi ne the poi nts i n any shape you l i ke by speci fyi ng the i n-phase and
quadrature components of each poi nt. You must defi ne the constel l ati on by
speci fyi ng two vector s, the i n-phase component vector (i nph) and the
ASK/PSK Constellation
ASK/PSK Constellation ASK/PSK Constellation
3-77
quadrature component vector (quad). The two vector s must be of equal vector
l ength. The two el ements i nph( k) and quad( k) defi ne a si ngl e poi nt i n the
constel l ati on. The el ements i n the two vector s ar e real number s. I n defi ni ng the
ar bi trary constel l ati on, the i n-phase and quadrature components mappi ng the
i nput symbol k ar e i nph( k+1) and quad( k+1) r especti vel y.
You can use ei ther
dmod( ' qas k/ar b' , i nph, quad)
or
modmap( ' qas k/ar b' , i nph, quad)
to pl ot the constel l ati on.
The ar bi tr ar y constel l ati on can r epresent both squar e and ci r cl e constel l ati ons.
For exampl e, you can generate the i n-phase and quadrature component vectors
used i n defi ni ng the ar bi tr ary constel l ati on fr om the square constel l ati on. The
commands are:
y = modmap( [ 0: M- 1] , 1, 1, ' qas k' , M) ;
modmap( ' qas k/ar b' , y( : , 1) , y( : , 2) ) ;
When M=32, the fi gur e gener ated i s the same as the pl ot shown i n the Square
Constel l ati on secti on.
You can defi ne any constel l ati on structure by usi ng a user -defi ned ar bi tr ar y
constel l ati on. For exampl e, you can defi ne a 16-ary hexagonal structure
constel l ati on by defi ni ng and pl otti ng the constel l ati on usi ng these commands.
% Lef t - hand pl ot , a he x agonal c ons t e l l at i on.
i nph = [ 1/2 1 1 1/2 1/2 2 2 5/2] ;
quad = [ 0 1 - 1 2 - 2 1 - 1 0] ;
i nph = [ i nph; - i nph] ; i nph = i nph( : ) ;
quad = [ quad; quad] ; quad = quad( : ) ;
modmap( ' qas k/ar b' , i nph, quad)
3-78
Si mi l arl y, you can defi ne a tr i angl e structure by assi gni ng the constel l ati on
i n-phase and quadr ature poi nts as i n the code bel ow:
% Ri ght - hand pl ot , a t r i angl e c ons t e l l at i on.
i nph = [ 1/2 - 1/2 1 0 3/2 - 3/2 1 - 1] ;
quad = [ 1 1 0 2 1 1 2 2] ;
i nph = [ i nph; - i nph] ; i nph = i nph( : ) ;
quad = [ quad; - quad] ; quad = quad( : ) ;
modmap( ' qas k/ar b' , i nph, quad)
The fi gure bel ow shows the pl ots of the hexagonal and tr i angl e constel l ati ons:.
The l eft pl ot i s the hexagonal constel l ati on, and the r i ght pl ot i s the tr i angl e
constel l ati on. The connecti on l i nes have been added ar ti fi ci al l y to show the
hexagonal and tri angl e structures. You can create any constel l ati on str ucture
by usi ng si mi l ar commands.
QASK Modulation/ Demodulation Example. Thi s exampl e demonstr ates the
quadrature ampl i tude shi ft keyi ng (QASK) modul ati on/demodul ati on method.
Gi ven the M-ar y number i s 16, a good choi ce for modul ati on and mappi ng i s to
use four -bi t messages mapped i nto a squar e constel l ati on.
Usi ng the tool box, you have the choi ce of doi ng the mappi ng and anal og
modul ati on separatel y usi ng the MATLAB functi ons modmap and amod or
QASK Constellation
QASK Constellation
3-79
combi ni ng them together usi ng amod al one. I n thi s exampl e, wel l do them
separ atel y:
% Numbe r of dat a poi nt s
N = 20;
% Random i nt eger s
x = r andi nt ( N, 1, 16) ;
% 16- QASK mappi ng wi t h Fd=1, Fs =100.
m = modmap( x , 1, 100, ' qas k' , 16) ;
% QAM modul at i on wi t h Fc=10.
y = amod( m, 10, 100, ' qam' ) ;
% demodul at i on wi t h ey e pat t e r n di agr am pl ot .
z = dde mod( y , 10, 1, 100, ' qas k/e ye ' , 16) ;
The or i gi nal si gnal i s mapped i nto i n-phase and quadr atur e components i n the
di gi tal to anal og mappi ng. The mapped si gnal i s modul ated usi ng the QAM
modul ati on method. You can then r ecover the ori gi nal di gi tal si gnal by usi ng
the QASK demodul ati on method.
Si nce f
s
>f
d
, i n the di gi tal demodul ati on pr ocess, the di gi tal demappi ng process
takes a sampl i ng poi nt fr om the anal og demodul ated si gnal . Thi s sampl i ng
poi nt i s known as the deci si on poi nt. As di scussed i n the Si gnal Generator s
and Di spl ay Devi ces secti on i n thi s chapter , an eye-patter n di agram i s
commonl y used to determi ne the deci si on poi nt. Thi s tool box provi des the
MATLAB functi on e ye s c at and, i n Si mul i nk, the Eye Patter n Scatter bl ock i n
the Sour ce/Si nk subl i br ary to hel p to fi nd the deci si on poi nt, whi ch shoul d be
the poi nt where the eye i s most wi del y open. I n the di gi tal demodul ati on and
demappi ng bl ocks, the deci si on poi nt i s set i n the parameter of f s e t of the
sampl e ti me var i abl e. I n the dde mod and demodmap functi ons, i t i s set i n the
of f s e t i n the di gi tal fr equency var i abl e.
The demodul ati on i n thi s exampl e uses the eye-patter n di agr am to fi nd the
deci si on poi nt. The si mul ati on pr ocess can be demonstrated by the data fl ow i n
the fol l owi ng fi gur e.
3-80
Figure 3-12: QAM Digital Signal Recovery Using an Eye-Pattern
Scatter Diagram
I n the fi gure, the x-axi s for ever y pl ot i s ti me (i n seconds). The y-axi s i s the
si gnal l evel . The ar rows show the data fl ow i n the si mul ati on.
M-ary Frequency Shift-Keying Modulation
M-FSK modul ati on modul ates a di gi tal si gnal by changi ng the fr equency of the
output si gnal dependi ng on the val ue of the i nput si gnal . Usi ng M-FSK, you
need to speci fy the tone space as an i nput par ameter. The tone space i s the
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
2
1
0
1
2
3
4
5
6
7
8
0 2 4 6 8 10 12 14 16 18 20
3
2
1
0
1
2
3
0 2 4 6 8 10 12 14 16 18 20
3
2
1
0
1
2
3
0 2 4 6 8 10 12 14 16 18 20
5
4
3
2
1
0
1
2
3
4
5
0 0.5 1 1.5 2 2.5 3
5
4
3
2
1
0
1
2
3
4
5
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
3
2
1
0
1
2
3
4 DPoint
time (second)
a
m
p
litu
d
e
EyePattern Diagram
0 2 4 6 8 10 12 14 16 18 20
0
5
10
15
zoom-i n
Q
A
M

m
a
p
p
i
n
g
d
i
g
i
t
a
l

m
o
d
u
l
a
t
i
o
n
ori gi nal di gi tal si gnal
r ecover ed di gi tal si gnal
eye-patter n scatter di agr am
quadrature component
i n-phase component
di gi tal demodul ati on
modul ated si gnal gen-
erated i n demodul ati on.
3-81
frequency separati on between two consecuti ve fr equenci es i n the modul ated
si gnal . The M-FSK modul ati on process di vi des i nto two parts: mappi ng and
anal og modul ati on. The mappi ng process maps the i nput symbol i nto the val ue
of the frequency shi ft from the carr i er fr equency, and the anal og modul ati on i s
anal og FM. I f the carr i er frequency i s Fc , M-ar y number M, and the tone space
f , then the fr equency r ange of a modul ated si gnal i s i n the r ange
[ Fc , Fc+( M- 1) f ] . You can use the MATLAB functi on modmap for M-FSK
mappi ng and the functi on dmod for the modul ati on. You can al so use the
Si mul i nk bl ocks i n the di gi tal modul ati on/demodul ati on subl i brar y for the
modul ati on.
The demodul ati on for the M-FSK i s di ffer ent from the other di gi tal
demodul ati on methods di scussed i n thi s secti on. The demodul ati on pr ocess
uses a l ength M vector si gnal where the fr equency of the i th el ement i n the
vector si gnal matches the modul ated si gnal when the i nput symbol i s i . The
demodul ati on pr ocess computes the corr el ati on val ues between the si gnal
ar ray and the r ecei ved si gnal and, after cal cul ati ng the maxi mum cor rel ati on
val ue, deci des what symbol was most l i kel y tr ansmi tted. Li ke other di gi tal
demodul ati on methods, M-FSK demodul ati on r equi r es the speci fi cati on of a
deci si on poi nt.
There ar e two di fferent methods to compute the corr el ati on val ue: the coherent
and noncoher ent methods. Usi ng the coherent method, you must know the
phase i nfor mati on of the modul ated si gnal fr om the r ecei vi ng si de. The
noncoher ent method does not r equi r e phase i nfor mati on; i t r ecovers the phase
of the modul ated si gnal duri ng the demodul ati on. However , the noncoher ent
demodul ati on method i s more computati onal l y compl ex than the coher ent
demodul ati on method.
Coherent Demodulation
Thi s fi gure depi cts the coherent M-FSK demodul ati on method:
3-82
Figure 3-13: Coherent M-FSK Demodulation Block Diagram
I n the fi gur e, Fc i s the carr i er fr equency, f i s the tone space, and i s the i ni ti al
phase i n the modul ated si gnal . T i s the symbol i nter val ; al ter nati vel y, 1/T i s the
di gi tal tr ansmi ssi on frequency. M i s the M-ar y number i n the modul ati on. The
si gnal c os ( 2( f
c
+( I - 1) f ) t +) is the modul ated si gnal for symbol I . The
i ntegrati ons depi cted i n the boxes ar e the cor rel ati on computati ons. I n the
coherent corr el ati on M-FSK demodul ati on, each i ntegr ator corr el ates the i nput
si gnal wi th a speci fi ed frequency and phase. The output of the corr el ators i s a
scal ar i ndex. The i ndex wi th the maxi mum cor rel ati on val ue i s i denti fi ed as the
demodul ati on r esul t.
Noncoherent Demodulation
Noncoherent M-FSK demodul ati on cal cul ates the cor rel ati on val ue between
the i nput si gnal and a vector of si nusoi dal si gnal s. Each si nusoi dal si gnal has
i ts frequency set to one of the possi bl e messages i n the si gnal set. Unl i ke the
coherent cor rel ati on method, thi s method i s i nsensi ti ve to the i ni ti al phase of
the modul ati on si gnal . The trade-off i s that the cal cul ati on of the noncoher ent
cor rel ati on i s mor e compl i cated si nce the noncoher ent method must recover the
(k+1)T
kT
(.) dt
(k+1)T
kT
(.) dt
(k+1)T
kT
(.) dt
Received
signal
Decision
digit
cos(2f
c
t+)
cos(2(f
c
+ f) t + )
cos(2(f
c
+ (M-1)f) t + )
Identify
index of
maximum
value
3-83
phase of the modul ated si gnal . The fi gure bel ow shows the noncoher ent M-FSK
demodul ati on method:
Figure 3-14: Noncoherent M-FSK Demodulation Block Diagram
The symbol s used i n the fi gur e are the same as the symbol s used i n the fi gure
for the coher ent M-FSK method.
(k+1)T
kT
(.) dt
Received
signal
Decision
digit
cos(2f
c
t+)
cos(2(f
c
+ f) t + )
cos(2(f
c
+ (M-1)f) t + )
sin(2f
c
t+)
sin(2(f
c
+ f) t + )
[ ]
2
(k+1)T
kT
(.) dt [ ]
2
(k+1)T
kT
(.) dt [ ]
2
(k+1)T
kT
(.) dt [ ]
2
+
+
(k+1)T
kT
(.) dt [ ]
2
(k+1)T
kT
(.) dt [ ]
2
+
sin(2(f
c
+ (M-1)f) t + )
Identify
index of
maximum
value
3-84
Simulink Example
The fol l owi ng Si mul i nk bl ock di agr am gi ves an exampl e of M-FSK modul ati on
usi ng both M-FSK coher ent and noncoher ent demodul ati on. Each of the
methods i s a combi nati on of two bl ocks:
M-FSK modul ati on i s a combi nati on of the M-FSK map bl ock and the FM
bl ock.
M-FSK coher ent demodul ati on i s a combi nati on of the Coherent M-FSK
Demodul ati on Cor rel ati on bl ock and the Mi n/Max demap bl ock.
M-FSK noncoher ent demodul ati on i s a combi nati on of the Noncoher ent
M-FSK demodul ati on correl ati on bl ock and the Mi n/Max demap bl ock.
Figure 3-15: Simulink Block Diagram of M-FSK Modulation
The Sampl ed Read Var i abl e bl ock generates the i nput symbol s. The Er ror Rate
Meter bl ock compar es the or i gi nal message si gnal and the si gnal s recovered
from the demodul ati on. The Graph1 scope bl ock shows the val ues of the
Sampled
read
variable Mux
Error Rate
Meter
.
MFSK modulation
FM
MFSK
map
.
MFSK coherence demodulation
Coherence
MFSK dm
corr
MFSK
demap
Graph1
.
MFSK noncoherence demodulation1
MFSK
demap
Noncohe
MFSK dm
corr
Graph2
3-85
cor rel ati on computati on for the coher ent corr el ati on cal cul ati on. The r esul t i s
shown i n the pl ot bel ow:
The Graph2 scope bl ock shows the val ues of the cor rel ati on computati on for the
noncoher ent cor rel ati on cal cul ati on. The next fi gure shows a snap shot from
the scope bl ock for the noncoherent M-FSK demodul ati on cor rel ati on
computati on:
I n the Mi n/Max Demap bl ock, you can set the offset i n the demappi ng. Usual l y,
a communi cati ons engi neer sets the offset the same way as the deci si on poi nt
i n the M-QASK demodul ati on pr ocessi ng, whi ch means that i t i s set to the ti me
poi nt where the si ngl e maxi mum val ue i s most wi del y separated from the other
val ues. Thi s i s si mi l ar to the method used i n determi ni ng the deci si on poi nt i n
the eye-patter n di agr am.
1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2
0.1
0.05
0
0.05
0.1
0.15
Time (second)
1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2
0
0.005
0.01
0.015
0.02
0.025
0.03
Time (second)
3-86
MATLAB Example
You can do the same si mul ati on descri bed i n the Si mul i nk exampl e usi ng
MATLAB functi ons. The command l i nes are:
% Def i ne t he f r e quency and t one s pac e.
Fc = 10; Fs = 40; Fd = 1; df = 1;
% As s ume M- ar y numbe r i s 4.
M = 4;
% Gener at e t he mes s age s i gnal .
x = r andi nt ( 100, 1, M) ;
% Modul at i on
y = dmod( x , Fc, Fd, Fs , ' f s k' , M, df ) ;
% Coher ent M- FSK demodul at i on wi t h pl ot .
z 1 = ddemod( y, Fc , Fd, Fs , ' f s k/e ye ' , M, df ) ;
% Noncohe r ent M- FSK de modul at i on wi t h pl ot .
z 2 = ddemod( y, Fc , Fd, Fs , ' f s k/e ye /nocoh' , M, df ) ;
% The e r r or r at e
s ymer r ( x, z 1)
ans =
0
s ymer r ( x, z 2)
ans =
0
I n the above code, the dde mod commands append the opti on ' /e y e' to the
met hod str i ng. Thi s opti on gener ates the pl ot of cor rel ati on val ues. The fi gur e
bel ow compar es the pl ots of coher ent and noncoher ent M-FSK demodul ati on:
3-87
The pl ot generated from the coher ent corr el ati on M-FSK demodul ati on i s
shown on the l eft-hand si de, and the pl ot generated from the noncoherent
cor rel ati on M-FSK demodul ati on i s shown on the ri ght. Note that the cur ves i n
the eye pattern pl ots ar e normal i zed cor rel ati on val ues; the pl ots are not the
conventi onal eye-pattern pl ots. You can use ei ther of these pl ots to determi ne
the offset val ue.
M-ary Phase Shift-Keying Modulation
M-PSK modul ati on modul ates a di gi tal si gnal by changi ng the phase val ues i n
the modul ated output si gnal . M-PSK di sti ngui shes between the di gi tal
messages by setti ng di fferent i ni ti al phase shi fts i n the modul ati on. The di gi tal
i nput si gnal s to a M-PSK modul ator ar e i n the r ange [0, M-1], wher e M i s the
M-ar y number. The phase shi ft for i nput di gi t i i s 2i /M.
The structur e of the demodul ator for M-PSK i s si mi l ar to that of M-FSK. The
demodul ati on pr ocess cal cul ates the corr el ati on val ue between the i nput si gnal
and a vector of car ri er fr equency si nusoi dal si gnal . Each si nusoi dal si gnal i n
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
0.5
0
0.5
1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
0.5
0
0.5
1
3-88
the vector has i ts phase set to a possi bl e resul t fr om the si gnal set. The fi gur e
bel ow shows the M-PSK demodul ati on method:
Figure 3-16: M-PSK Demodulation Block Diagram
I n the fi gure, f
c
i s the car ri er fr equency, i s the i ni ti al phase for di gi t i , and
T i s the symbol per i od, meani ng that 1/ T i s the baud rate. Note that the
M-PSK demodul ati on i s a coherent cor rel ati on computati on; you must pr ovi de
the phase i nfor mati on.
(k+1)T
kT
(.) dt
(k+1)T
kT
(.) dt
(k+1)T
kT
(.) dt
Received
signal
Decision
digit
cos(2f
c
t +
0
)
cos(2f
c
t +
1
)
cos(2f
c
t +
M-1
)
Identify
index of
maximum
value
3-89
3
Baseband Modulation and Demodulation
The Nyqui st sampl i ng theorem requi res that a si mul ati on sampl i ng fr equency
must be at l east twi ce the fr equency f
c
bei ng model ed. I n passband si mul ati on,
the si mul ati on model s the car ri er fr equency. Si nce the carr i er frequency i s
usual l y a hi gh frequency si gnal , model i ng passband communi cati on systems
i nvol ves hi gh computati onal l oads. To al l evi ate thi s probl em, baseband
si mul ati on techni ques ar e used.
Baseband si mul ati on, al so known as the l ow-pass equi val ent method, uses the
compl ex envel ope of a passband si gnal . As an exampl e, consi der anal og
quadrature ampl i tude modul ati on. Assume the carr i er fr equency i s f
c
and the
i ni ti al phase i s
0
. The equati on for modul ati ng the i n-phase si gnal x
I
(t) and the
quadrature si gnal x
Q
(t) by the car ri er fr equency i s
whi ch i s equi val ent to
where
i s cal l ed the complex baseband waveform. The hi gh frequency component i s:
Baseband si mul ati ons model the compl ex baseband waveform Y(t) onl y.
Let B be the bandwi dth of the message si gnal . The baseband si mul ati on
requi res the si mul ati on sampl i ng r ate to be l ar ger than 2B. I n the baseband
si mul ati on, the si gnal bandwi dth i s al ways assumed to be much smal l er than
the carr i er fr equency, or B << f
c
.
The output of a baseband modul ator and the i nput to a baseband demodul ator
ar e compl ex si gnal s. The fi gur e bel ow shows the si gnal data type at each step
of the baseband modul ati on/demodul ati on process:
y t ( ) x
I
t ( ) 2f
c
t
0
+ ( ) cos x
Q
t ( ) 2f
c
t
0
+ ( ) si n =
y t ( ) Re x
I
t ( ) j x
Q
t ( ) + ( )e
j
0
e
j 2f
c
t

' ;

Re Y t ( )e
j 2f
c
t
{ } = =
Y t ( ) x
I
t ( ) j x
Q
t ( ) + ( )e
j
0
=
e
j
0
3-90
To demodul ate a baseband modul ated si gnal , a baseband demodul ator must be
used. There i s a di ffer ence between the way MATLAB and Si mul i nk handl e the
data gener ated i n a baseband modul ati on/demodul ati on si mul ati on. I n
MATLAB functi ons, the output data type of a baseband modul ated si gnal i s a
compl ex number. I n Si mul i nk bl ocks, al l data i s r eal , so compl ex data i s
repr esented by usi ng a two-di mensi onal vector wher e each component i s a real
scal ar . The fi r st el ement i n the vector represents the real par t of the compl ex
number, and the second el ement repr esents the i magi nar y part. I n Si mul i nk
bl ocks, al l output ports that output compl ex si gnal s ar e mar ked wi th an
aster i sk. Al l i nput por ts that expect compl ex i nput si gnal s ar e al so mar ked
wi th an aster i sk.
The fol l owi ng secti ons di scuss i n tur n:
Baseband anal og modul ati on
Baseband anal og demodul ati on
Baseband di gi tal modul ati on
Baseband di gi tal demodul ati on
Baseband Analog Modulation
Thi s secti on di scusses baseband anal og modul ati on techni ques. Thi s tool box
suppor ts si x baseband anal og modul ati on techni ques:
Doubl e si deband-suppr essed car ri er anal og modul ati on (DSB-SC AM)
Si ngl e si deband-suppressed car ri er anal og modul ati on (SSB-SC AM)
Doubl e si deband-car ri er anal og modul ati on (DSB-TC AM)
Quadrature ampl i tude modul ati on (QAM)
Fr equency modul ati on (FM)
Phase modul ati on (PM)
Baseband
modul ati on
Baseband
demodul ati on
Baseband
channel
Real
si gnal
Real
si gnal
Compl ex
si gnal
Compl ex
si gnal
* * * *
3-91
These methods are si mi l ar to thei r passband counterparts. Refer to the
di scussi on i n the Passband Anal og Modul ati on and Demodul ati on secti on of
thi s chapter for descri pti ons of the passband modul ati on techni ques.
I n the baseband anal og modul ati on techni ques provi ded i n thi s tool box, the
output di vi des i nto i n-phase and quadr atur e components. The i nput to the
modul ator i s a r eal si gnal u(t), except for quadratur e ampl i tude modul ati on,
where the i nput si gnal has two el ements, the i n-phase component and the
quadrature component, u
I
(t) and u
Q
(t) r especti vel y Thi s tabl e l i sts the real part
of the modul ati on output x
I
(t) and the i magi nar y part x
Q
(t) for each modul ati on
method:
x
I
(t) and x
Q
(t) ar e the outputs when the modul ati on phase shi ft i s zero. The
modul ated si gnal i s repr esented i n i ts compl ex envel ope for m:
Modulation
Method
x
I
(t) x
Q
(t) Optional
Parameters
DSB-SC AM u(t) 0
SSB-SC AM u(t) , Hi l ber t
transform of
u(t).
DSB-TC AM u(t)-k 0 k i s modul ati on
offset.
QAM u
I
(t) u
Q
(t)
FM k i s modul ati on
sensi ti vi ty
PM k i s modul ati on
sensi ti vi ty
u t ( )
k u ( ) d

,
_
cos k u ( ) d

,
_
si n
ku t ( ) ( ) cos ku t ( ) ( ) si n
Y t ( ) x
I
t ( ) j x
Q
t ( ) + ( )e
j
R t ( )e
j t ( )
= =
3-92
where i s the car ri er phase shi ft, R(t) i s the real envel ope, whi ch i s
; and i s the phase of the envel ope:
The compl ex si gnal Y(t) i s the output of both the MATLAB functi ons and the
Si mul i nk bl ocks i n baseband si mul ati on.
Baseband Analog Demodulation
Thi s secti on di scusses the baseband anal og demodul ati on of the modul ated
compl ex si gnal Y(t) defi ned i n the l ast secti on.
Y(t) may be di stor ted by noi se, bandwi dth l i mi tati ons, or other unwanted
effects i n the tr ansmi ssi on channel . Thi s di stor ted si gnal i s r epr esented by Z(t).
The demodul ati on must r ecover the message si gnal u(t) (u
I
(t) and u
Q
(t) for
QAM) fr om the recei ved compl ex si gnal Z(t). Demodul ati on can be di vi ded i nto
two methods: coherent and noncoherent demodul ati on. Coherent demodul ati on
requi res exact knowl edge of the frequency and phase of the carr i er frequency
to r ecover the si gnal corr ectl y. Noncoher ent demodul ati on permi ts the r ecover y
of the message si gnal wi thout exact knowl edge of the carr i er si gnal s fr equency
and phase, but thi s method adds computati onal compl exi ty and performance
degr adati on. The noncoherent demodul ati on method i s not avai l abl e for ever y
modul ati on scheme; the coher ent demodul ati on method i s al ways avai l abl e.
Coher ent Demodula tion
Thi s equati on repr esents the r ecei ved si gnal Z(t) by i ts i n-phase and
quadrature components:
I n thi s equati on, i s the r ecei ved carr i er si gnal fr equency and i s i ts phase.
f
c
and ar e the transmi tted car ri er si gnal frequency and phase. The si gnal u(t)
(u
I
(t) and u
Q
(t) for QAM) can be r ecover ed by r efer ri ng to the tabl e gi ven i n the
Baseband Anal og Modul ati on secti on of thi s chapter usi ng the esti mated
si gnal z
I
(t) and z
Q
(t). The demodul ati on phase shi ft and the carr i er frequency
esti mati on er ror can be cal cul ated by usi ng the phase l ocked l oop (PLL)
x
I
t ( ) x
Q
t ( ) +
=
x
I
t ( )
x
Q
t ( )
-------------- atan +
z
I
t ( ) j z
Q
t ( ) + Z t ( )e
j 2 f
c
f
c

( ) j

( ) +
=
f
c

f
c
f
c

3-93
techni que. The Synchroni zati on secti on of thi s chapter provi des a detai l ed
di scussi on of the PLL techni que.
N oncoher ent Demodula tion
The noncoherent demodul ati on scheme can be used wi th the DSB-SC AM,
DSB-TC AM, FM, and PM methods to detect a modul ated si gnal .
For an AM wi th car ri er si gnal , an envel ope detecti on method can be used for
noncoher ent demodul ati on. Thi s method detects the si gnal i n the form:
When the r ecei ved si gnal i s represented i n pol ar form , the
detected PM si gnal i s si mpl y and the FM si gnal i s the deri vati ve of
the PM si gnal :
The baseband waveform PLL si mul ati on method can al so be used for
noncoher ent demodul ati on. The method i s di scussed i n the Passband Anal og
Modul ati on and Demodul ati on secti on of thi s chapter. For di scussi ons of the
FM and PM methods, refer to the Passband Fr equency Modul ati on and
Demodul ati on and Passband Phase Modul ati on and Demodul ati on secti ons
of thi s chapter.
Baseband Digital Modulation
As di scussed i n the Passband Di gi tal Modul ati on and Demodul ati on secti on
of thi s chapter , the functi onal i ty of di gi tal modul ati on can be di vi ded i nto two
parts: the mappi ng from di gi tal si gnal to anal og si gnal , and anal og modul ati on.
The Passband Di gi tal Modul ati on and Demodul ati on secti on of thi s chapter
di scusses di gi tal mappi ng methods.
I n the r est of thi s secti on, the mappi ng and modul ati on processes ar e anal yzed
together as one method. Assume the i nput message has M-ar y number M. The
i nput i s an i nteger i n the range [0, M-1]. Most di gi tal modul ati on methods can
x

t ( ) Z t ( )

k =
Z t ( ) R t ( )e
j t (
=
x t ( ) t ( ) =
x t ( )
t d
d
t ( ) =
3-94
use the baseband si mul ati on formul as gi ven i n the Baseband Anal og
Modul ati on secti on:
The sampl i ng fr equenci es for x
1
(t) and x
2
(t) are 1/ T
1
and 1/ T
2
respecti vel y.Ther e may be del ays i n the transfer ti mes for x
1
(t) and x
2
(t); these
del ays ar e r epr esented by D
1
and D
2
respecti vel y.
There i s a mathemati cal r epr esentati on for si gnal s x
1
(t) and x
2
(t) that al l ows
for a uni fi ed approach to several i mportant di gi tal modul ati on schemes. Let
functi on p
1
(t) be a pul se functi on wi th pul se l ength T
1
. The equati on for p
1
(t) i s
where u(t) i s the uni t step functi on.
I n other wor ds, p
1
(t) i s nonzero i n a T
1
l ength ti me frame and zer o el sewhere:
Si mi l arl y, a pul se functi on p
2
(t) of l ength T
2
can be defi ned. The r eal and the
i magi nar y components, x
1
(t) and x
2
(t), are:
Thi s gener al for mul a al l ows us to speci fy M-ary ASK, M-ary QASK wi th squar e
or arbi trary constel l ati ons, and M-ary PSK usi ng onl y the par ameters A
k
, B
k
,
y t ( ) x
1
t ( ) 2f
c
t + ( ) cos x
2
t ( ) 2f
c
t + ( ) si n =
Y t ( ) x
1
t ( ) j x
2
t ( ) + ( )e
j
R t ( )e
j t ( )
= =
p
1
t ( ) u t ( ) u t T
1
( ) =
t
p
1
(t-d)
1
d d+T
1
x
1
t ( ) A
k
p
1
t kT
1
D
1
( )
k

=
x
2
t ( ) B
k
p
2
t kT
2
D
2
( )
k

=
3-95
T
1
, T
2
, D
1
, and D
2
. For more i nformati on about thi s mathemati cal
repr esentati on, r efer to Jeruchi m, Bal aban, and Shanmugan, Simulation of
Communication Systems, pp. 328-9.
X(t) = x
1
(t) + j x
2
(t) i s the modul ated si gnal wi th a zer o i ni ti al phase shi ft i n the
modul ati on. Thi s tabl e l i sts mathemati cal formul ae for A
k
, B
k
, p
1
(t), and p
2
(t):
I n the tabl e, n i s the i nteger i nformati on to be transferr ed i n the ti me frame,
whi ch i s i n the range of [0, M-1]. The tabl e doesnt l i st parameter s for QASK
wi th ci r cl e constel l ati on. Thi s i s because ci r cl e constel l ati ons can be vi ewed as
a speci al case of the arbi trar y constel l ati on method. Gi ven the vector s: ni c
(number i n ci rcl e), r i c (r adi i i n ci rcl e), and pi c (phase i n ci rcl e), you can obtai n
Modulation
Method
A
k
B
k
P
1
(t) P
2
(t) Parameters
M-ary ASK 0 1; 0 A
c
: peak
ampl i tude.
M-ary QASK
wi th squar e
constel l ati on
s
1
(n+1) s
2
(n+1) 1; p
1
(t) s
1
and s
2
ar e
output from
command
[ s 1, s 2] =
qas ke nc o
( [ 0: M- 1] , M) ;
M-ary QASK
wi th
arbi trar y
constel l ati on
Re(inph(n+1)) I m(quad(n+1)) 1; p
1
(t) inph and quad
ar e l ength M
vectors defi ni ng
the i n-phase
component and
quadratur e
component of the
ar bi tr ary
constel l ati on.
M-ary PSK cos(2n/ M) sin(2n/ M) 1; p
1
(t) T
1
=T
2
, D
1
=D
2
.
n
M 1
2
-------------- -
,
_
2A
c
M 1
-------------- -
,
_
0 t T
1

0 t T
1

0 t T
1

0 t T
1

3-96
the i n-phase component i nph and quadrature component quad by usi ng the
commands:
z = apkcons t ( ni c , r i c , pi c) ;
i nph = r e al ( z ) ;
quad = i mag( z ) ;
The modul ated si gnal r epr esented i n ter ms of the modul ati on phase shi ft i s:
M-ar y frequency shi ft-keyi ng (M-FSK) and mi ni mum shi ft-keyi ng (MSK) do
not fi t the mathemati cal model descr i bed above. These two modul ati on
methods ar e known as continuous phase shift-keying methods. Some di gi tal
modul ati on methods cannot be di r ectl y r epresented by the formul a as
presented above. Another gener al for m modul ated si gnal i s gi ven by:
The compl ex envel ope for mul a i s gi ven by:
For M-FSK, (t) i s a vari abl e changi ng wi th the val ue of the di gi tal i nput. The
val ue of (t) i s
where n
k
i s the i nput i nteger at computati on step k. Var i abl e h i s the tone
space, whi ch i s the mi ni mum frequency di ffer ence between two modul ated
consecuti ve di ffer ent symbol s.
I f M=2 and h=1/2, thi s i s a speci al case of FSK known as MSK, whi ch i s a
wi del y used method. I n thi s case, the phase functi on (t) becomes.
Y t ( ) X t ( )e
j
=
y t ( ) A 2f
c
t
0
t ( ) + + ( ) cos =
Y t ( ) Ae
j
0
j t ( ) +
=
t ( ) h n
k
t kT ( )
T
-------------------- n
i
i k <

+
,

_
= kT t k 1 + ( )T
t ( )

2
--- n
k
t kT ( )
T
-------------------- n
i
i k <

+
,

_
= kT t k 1 + ( )T
3-97
Baseband Digital Demodulation
I n gener al , the di gi tal demodul ati on process can be di vi ded i nto two parts: the
anal og demodul ati on and the di gi tal demappi ng, except i n the case of M-ary
frequency shi ft-keyi ng (M-FSK) and M-ary phase shi ft-keyi ng (M-PSK), wher e
a corr el ati on computati on method i s used. The methods used i n the di gi tal
demodul ati on for baseband si mul ati on ar e di scussed i n pr evi ous secti ons.
Si mi l ar to the baseband anal og demodul ati on methods, i n the baseband
si mul ati on demodul ati on pr ocess, you need to speci fy the deci si on poi nt for
demappi ng. To match the for mul a descri bed i n the l ast secti on, you need to
determi ne D
i
, i = 1, 2, fr om the r ecei vi ng si de. The demodul ati on process i s the
rever se of the modul ati on process. Usi ng the r ecei ved si gnal Z(t) =z
I
(t) + j z
Q
(t),
whi ch i s the modul ated si gnal Y(t) passed through a tr ansmi tti ng channel , the
demodul ati on r ecover s the transmi tted si gnal s s
1
(t) and s
2
(t).
The baseband si mul ati on M-FSK demodul ati on and M-PSK demodul ati on
al gor i thms are the same as those used i n passband si mul ati on methods i n
whi ch corr el ati on computati ons are used. Pl ease refer the di scussi on i n the
Anal og Modul ati on and Demodul ati on secti on.
Using the Baseband Simulation Functionality
in the Toolbox
Thi s tool box provi des baseband si mul ati on MATLAB functi ons as wel l as
Si mul i nk bl ocks i n paral l el wi th the passband si mul ati on. I n the Si mul i nk
Modul ati on/Demodul ati on subl i brary, ther e ar e baseband modul ati on/
demodul ati on subl i brar i es next to ever y passband modul ati on/demodul ati on
3-98
subl i br ary. I n the MATLAB functi on l i br ary, ther e i s a baseband si mul ati on
functi on for ever y passband modul ati on/demodul ati on functi on as l i sted bel ow:
The choi ces for the anal og modul ati on/demodul ati on ar e amds b- s c, amds b- t c ,
ams s b, qam, f m, and pm. The choi ces for the di gi tal modul ati on/demodul ati on
and di gi tal mappi ng/demappi ng methods are as k, qas k, qas k/c i r cl e , qas k/
ar b, f s k, ps k, and s ampl e . s ampl e, whi ch changes the sampl i ng r ate of the
i nput si gnal , i s a uti l i ty that suppor ts modul ati on techni ques.
I n baseband si mul ati on, ther e i s no car ri er frequency i nvol ved. Ther efor e, the
computati on sampl i ng fr equency for baseband si mul ati on can be much l ower
than that i n a passband si mul ati on. The onl y frequency used i n baseband
anal og modul ati on i s the computati on sampl i ng fr equency fs. By Nyqui st
sampl e theor y, fs shoul d be at l east twi ce as l ar ge as the bandwi dth of the i nput
si gnal . I n baseband di gi tal si mul ati on, ther e ar e two frequenci es i nvol ved: the
computati on sampl i ng fr equency fs and the di gi tal tr ansfer ri ng frequency fd.
fs must be l ar ger than fd, and usual l y fs/fd i s a posi ti ve i nteger.
The passband demodul ati on di scussi on emphasi zes the i mportance of the
l owpass fi l ter s. The l owpass fi l ters al so appl y to baseband si mul ati on. Because
the computati on sampl i ng fr equency i s di ffer ent between baseband and
passband si mul ati on, the effect of the l owpass fi l ter s on demodul ati on i s al so
di fferent. I f the effect of l owpass fi l ter s i snt i mportant i n your appl i cati on, you
can set both the numer ator and denomi nator of the l owpass fi l ter to one.
Baseband Function Passband Function Functionality
amod amodc e Anal og modul ati on
ade mod ade mod Anal og demodul ati on
dmod dde mod Di gi tal modul ati on
dde mod dde mod Di gi tal demodul ati on
modmap modmap Di gi tal mappi ng
demodmap demodmap Di gi tal demappi ng
3-99
Ba seba nd Simula ti on Ex a mple
Thi s exampl e compar es baseband si mul ati on r esul ts by usi ng Si mul i nk bl ock
di agr ams and MATLAB functi ons. The fol l owi ng Si mul i nk bl ock di agr am
i ncl udes the avai l abl e baseband modul ati on/demodul ati on methods. The
modul ati ons methods i ncl uded i n the si mul ati on ar e: DBS-SC AM,
DBS-TC AM, FM, PM, SSB AM, and QAM. I n the bl ock di agram, two Si gnal
Gener ator bl ocks ar e used as si gnal source. The fi rst Si gnal Generator
gener ates a 1 Hz si nusoi dal si gnal . The second Si gnal Generator generates a 2
Hz sawtooth si gnal . The second si gnal sour ce i s used as the quadr ature
component for QAM onl y. The computati on sampl e fr equency set i n the
si mul ati on i s 100 Hz. Thi s fi gur e shows the Si mul i nk bl ocks used to compare
the avai l abl e baseband modul ati on/demodul ati on methods:
Figure 3-17: Simulink Block Diagram for Comparing Baseband
Modulation/ Demodulation Methods
Defaults in this simulation: ts=0.01; [num,den]=butter(2,Fc*2*ts);
10
Outport9
9
Outport8
8
Outport7
7
Outport6
6
Outport5
5
Outport4
4
Outport3
3
Outport2
2
Outport1
1
Outport
Signal
generator1
Signal
generator
SSB AM SSB ADM
QAM QADM
PM PDM
FM FDM
Demux
Demux
DSB ADM DSB AM
AM w TC ADM w TC
3-100
Usi ng the MATLAB commands
t ut modc e
[ t , x, yout ] = e ul er ( ' t ut modc e' , 1)
i nvokes thi s Si mul i nk bl ock di agram for a one mi nute si mul ati on. The
si mul ati on ti me i s vari abl e t . The si mul ati on pl aces each output i n a col umn of
the vector yout .
I n the MATLAB si mul ati on, the sampl e ti me and the l owpass fi l ter s are set to
the same val ues as those used i n the Si mul i nk bl ock di agr am. The comments
3-101
i n the code refer to the fi gur e on the fol l owi ng page, whi ch compares the
MATLAB and Si mul i nk baseband modul ati on/demodul ati on r esul ts:
% Sampl i ng f r e quency
f s = 100;
% Lowpas s f i l t er
[ num, de n] = but t er ( 2, 100/2/pi /f s ) ;
% DSB- SC AM s i mul at i on r e s ul t s - t op l ef t pl ot .
y = amodc e( y out ( : , 1) , 1/t s , ' amds b- s c' ) ;
x = ade modc e ( y , 1/t s , ' amds b- s c /c os t as ' , num, den) ;
pl ot ( t , y out ( : , 1) , t , x , ' y - - ' , t , y out ( : , 2) , y - - )
% DSB- TC AM s i mul at i on r e s ul t s - t op r i ght pl ot .
y = amodc e( y out ( : , 1) , 1/t s , ' amds b- t c' , 1) ;
x = ade modc e ( y , 1/t s , ' amds b- t c /c os t as ' , 1, num, de n) ;
pl ot ( t , y out ( : , 1) , t , x , ' y - - ' , t , y out ( : , 3) , y - - )
% FM s i mul at i on r e s ul t s - mi ddl e l e f t pl ot .
y = amodc e( y out ( : , 1) , 1/t s , ' f m' ) ;
x = ade modc e ( y , 1/t s , ' f m' , num, de n) ;
pl ot ( t , y out ( : , 1) , t , x , ' y - - ' , t , y out ( : , 4) , y - - )
% PM s i mul at i on r e s ul t s - mi ddl e r i ght pl ot .
y = amodc e( y out ( : , 1) , 1/t s , ' pm' ) ;
x = ade modc e ( y , 1/t s , ' pm' , num, de n) ;
pl ot ( t , y out ( : , 1) , t , x , ' y - - ' , t , y out ( : , 5) , y - - )
% SSB AM s i mul at i on r e s ul t s - bot t om l ef t pl ot .
[ num_h, den_h] = hi l bi i r ( t s , 10t s , 10) ;
y = amodc e( y out ( : , 1) , 1/t s , ' ams s b/t i me' , num_h, de n_h) ;
x = ade modc e ( y , 1/t s , ' ams s b' , num, de n) ;
pl ot ( t , y out ( : , 1) , t , x , ' y - - ' , t , y out ( : , 6) , y - - )
% QAM s i mul at i on r es ul t s - bot t om r i ght pl ot .
% The r e ar e t wo i nput s i gnal s f or t he QAM modul at i on, t he i n-
%phas e component and t he quadr at ur e compone nt . The pl ot c ompar es
% bot h compone nt s .
y = amodc e( [ yout ( : , 1) , yout ( : , 9) ] , 1/t s , ' qam' ) ;
x = ade modc e ( y , 1/t s , ' qam' , num, de n) ;
pl ot ( t , y out ( : , 1) , t , x , ' y - - ' , t , y out ( : , 4) , y - - )
3-102
The Si mul i nk si mul ati on r esul ts ar e pl otted agai nst the MATLAB si mul ati on
resul ts together wi th the or i gi nal i nput si gnal source. Thi s fi gur e i ncl udes pl ots
for each modul ati on method:
Figure 3-18: A Comparison of MATLAB and Simulink Simulation of
Baseband Modulation/ Demodulation Methods
The sol i d cur ves ar e the ori gi nal i nput si gnal s. The dotted curves ar e the
Si mul i nk resul ts. The dashed cur ves are the MATLAB r esul ts. Because the
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
amdsbsc
0 0.2 0.4 0.6 0.8 1
1
0.5
0
0.5
1
amdsbtc
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
fm
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
pm
0 0.2 0.4 0.6 0.8 1
0
0.2
0.4
0.6
0.8
1
amssb
0 0.2 0.4 0.6 0.8 1
1
0.5
0
0.5
1
qam
3-103
di ffer ences between the Si mul i nk and MATLAB r esul ts are smal l (wi thi n
numeri cal accur acy), the dotted and dashed cur ves overl ap and cannot be
di sti ngui shed. The r ecovered si gnal can be di sti ngui shed from the i nput
si gnal s by the ti me l ags evi dent i n each pl ot. The l owpass fi l ters cause thi s
del ay between the or i gi nal si gnal and the r ecovered si gnal . The l owpass fi l ter s
al so remove the hi gh frequency par t of the saw-tooth si gnal .
3-104
Signal Multiple Access
Si gnal multiple access i s a techni que that al l ows shari ng of fi xed
communi cati on r esources by mul ti pl e users. Most moder n communi cati on
tr ansmi tti ng r esour ces are shar ed by mul ti pl e users. A typi cal mul ti pl e access
communi cati on system i s shown i n the fol l owi ng fi gure. A mul ti pl e access bl ock
on the transmi tti ng si de col l ects al l i nfor mati on to be transferr ed i n a speci fi ed
sequence and sends the i nformati on through the tr ansmi tti ng channel . A
mul ti pl e access bl ock on the r ecei vi ng si de recovers the i ndi vi dual si gnal s and
di vi des the si gnal s among the i ndi vi dual r ecei ver s i n a speci fi ed sequence.
Figure 3-19: Multiple Access Block Diagram
The tool box i ncl udes four di ffer ent mul ti access techni ques:
Ti me-shar e mul ti pl exi ng and demul ti pl exi ng
TDMA (ti me di vi si on mul ti pl e access)
FDMA (frequency di vi si on mul ti pl e access)
CDMA (code di vi si on mul ti pl e access)
The fol l owi ng secti ons di scuss each of these methods i n tur n.
Time-Share Multiplexing and Demultiplexing
The fi gur e bel ow shows an exampl e of ti me-shar e mul ti pl exi ng and
demul ti pl exi ng. The i nput i s a l ength 3 vector si gnal . The thr ee i nput si gnal s
Transmitter 1
Transmitter 2
Transmitter 3
Transmitter N
Receiver 1
Receiver 2
Receiver 3
Receiver M
Multiple
Access
Multiple
Access
Channel
3-105
ar e shown on the l eft si de of the fi gure. The backgr ound shades of the pl ots are
carr i ed on to each stage of the ti me-share process. The mi ddl e pl ot i s the resul t
of the ti me-shar e process, whi ch i s a scal ar si gnal . The pl ots on the ri ght ar e
the si gnal s r ecover ed from the ti me-share si gnal . I n thi s exampl e, the ti me
i nter val [kT, (K+1)T] i s di vi ded i nto three secti ons. The ti me i nterval for each
secti on i s T/3. The fi rst si gnal takes the fi r st secti on; the second si gnal takes
the second secti on; and the thi r d si gnal takes the thi r d secti on. The recovery
si de uses the same ti me-shari ng di vi si on.
Figure 3-20: Time-Share Multiplex/ Demultiplex Example
On the r ecei vi ng si de, the ti me-shar e process sends the ti me-shar e si gnal to
whi chever output si gnal has the al l otted ti me sl ot. You have a choi ce about
what the other output si gnal s do duri ng the ti mes dur i ng whi ch they have no
access to the ti me-share si gnal . They can ei ther output zer o val ues or hol d the
l ast val ue they r ecei ved when thei r al l otted ti me occured i n the transfer per i od.
I n the above exampl e, the si gnal s output zer os duri ng the ti mes i n whi ch they
had no access to the ti me-shar e si gnal .
time-share signal
signal 1
signal 2
signal 3
signal 1
signal 2
signal 3
TDMA
mul ti pl e
access
TDMA
demul ti pl e
access
0 T/3
2T/3 T 4T/3 5T/3 2T
0 T/3 2T/3 T 4T/35T/3 2T
0
T/3
2T/3
T
4T/3
5T/3
2T
3-106
Vector Signa l Redi str ibution
I n ti me-share mul ti pl exi ng, when an output si gnal does not have access to a
ti me sl ot, i t ei ther i s zer o or hol ds i ts most r ecent val ue.I n the ti me-share
mul ti pl exi ng exampl e i n the l ast secti on, si ne waves went to the fi r st output,
tr i angl e waveforms went to the second output, and square waves went to the
thi rd output. Wi th the Vector Redi str i butor bl ock, i t i s possi bl e to combi ne and
rear range ti me-share si gnal s i n ar bi tr ary sequences. Thi s fi gure shows an
exampl e of the vector redi stri buti on:
Figure 3-21: Vector Redistribution Example
I n thi s exampl e, ther e ar e three i nput and output si gnal s. The output si gnal s
ar e a redi str i buti on of the i nput si gnal s. Reorderi ng the i nput si gnal s i nto the
output si gnal s i s done each ti me a tri gger si gnal occur s. To r ecover the ori gi nal
Input 1
Input 2
Input 3
Time Domain Signal
Vector
Redis-
tribution
t0 t2 t1 t3 t4
t0 t2 t1 t3 t4
Time Domain Signal
Trigger signal
t0 t2 t1 t3 t4
Output 1
Output 2
Output 3
3-107
si gnal , use the Vector Redi stri butor bl ock agai n to r earr ange the i nput si gnal
i nto the i nverse of the fi r st redi stri buti on.
Time Division Multiple Access (TDMA)
TDMA i s a mul ti pl e access techni que that di vi des a si ngl e transmi tti ng ti me
peri od i nto ti me shari ng secti ons. Each i nput si gnal takes one ti me sl ot for each
ti me per i od i n the transmi ssi on. I n thi s tool box, i t i s assumed that there i s
some number, N, of i nputs that must share the communi cati on channel . Each
i nput has excl usi ve access to the channel dur i ng i ts assi gned ti me sl ot, but i t
cannot tr ansmi t at other ti mes. The channel must have adequate bandwi dth to
accommodate the needs of al l the i nputs.
Di gita l TDM A
Di gi tal TDMA i s a mul ti pl e access method that gi ves access to the
communi cati on channel to each of a number of i nputs for a l i mi ted ti me peri od.
Onl y one i nput has access to the channel at any gi ven ti me, and the method
rotates through each i nput i n a peri odi c fashi on. Data i s transmi tted over the
channel ser i al l y, and the channel data rate must be suffi ci entl y hi gh so that
accumul ated data at each i nput can be tr ansmi tted wi thi n i ts avai l abl e ti me
sl ot. Compr essi on of the ti me scal e of the i nputs i s equi val ent to bandwi dth
expansi on so that the data from each i nput can be tr ansmi tted wi thi n i ts
al l otted ti me fr ame.
I n the exampl e pi ctur ed bel ow, ther e are 3 i nputs. The background of the each
i nput el ement i ndi cates the ti me that each si gnal occupi es i n the TDMA si gnal .
The ti me i nter val for each peri od i s T. For N i nputs, the sampl i ng ti me for the
TDMA si gnal i s T/N. The recovered output si gnal from TDMA has a sampl i ng
ti me T and the i th el ement i n the output si gnal has offset as (i -1)T/N. There i s
no speci al l i mi tati on for the i nput si gnal . The i th output el ement i s equi val ent
to the sampl i ng of the i th i nput el ement wi th sampl i ng ti me T and offset (i -1)T/
N. When the i nput si gnal has the exact sampl e ti me and offset, the si gnal
output i s exactl y the same as the i nput si gnal .
3-108
Figure 3-22: Digital TDMA Example
Thi s tool box provi des both anal og and di gi tal TDMA bl ocks i n the Si mul i nk
bl ock l i br ary.
Frequency Division Multiple Access (FDMA)
FDMA i s a techni que wi del y used i n radi o frequency transmi tti ng. A
tr ansmi tti ng resour ce i s shared by a number of transmi tti ng sources. Each
tr ansmi tti ng sour ce takes a speci al assi gned fr equency i nter val . Usual l y,
bui l di ng a FDMA system i nvol ves modul ati on techni ques. You can use the
modul ati on method of your choi ce to modul ate the message si gnal .
Modul ati on can be used to move the frequency range occupi ed by a si gnal to a
di fferent par t of the frequency spectrum by sel ecti ng an appropr i ate car ri er
frequency. I n thi s way a number of si gnal s can be transmi tted over a channel
provi ded that the over al l bandwi dth of that channel i s wi de enough to
accommodate the sum of the i ndi vi dual si gnal bandwi dths. Usual l y, bandpass
fi l ter i ng i s needed to reduce i nter fer ence and crosstal k between the di fferent
si gnal s.
An FDMA exampl e i s shown i n the fol l owi ng fi gure. Thr ee message si gnal s ar e
modul ated i nto f
1
, f
2
, and f
3
r especti vel y. Assume the l ower bound for the i th
modul ated si gnal i s f
i
-B
i
and the upper bound of the fr equency i s f
i
+B
i
. I t i s al so
assumed that f
i+1
+B
i+1
< f
i
-B
i
, for i =1,2,3.
signal 1
signal 2
signal 3
TDMA signal
0
T 2T 3T 4T
T/3 4T/3 7T/3 10T/3
2T/3 5T/3 8T/3 11T/3
0
T 2T 3T 4T
T/3
4T/3
7T/3
10T/3
2T/3 5T/3 8T/3 11T/3
signal 1
signal 2
signal 3
0 T 2T 3T 4T
T/3
4T/3 7T/3 10T/3
2T/3 5T/3 8T/3 11T/3
Di gi ti ze wi th sampl i ng
ti me T and offset 0
Di gi ti ze wi th sampl i ng
ti me T and offset 2T/3
3-109
Figure 3-23: FDMA Example
The mul ti pl e accessed si gnal i s shown i n the mi ddl e of the fi gur e. On the
recei vi ng si de, the recei ved si gnal goes through a bandpass fi l ter. Then a
demodul ati on pr ocess recovers the si gnal as shown i n the pl ots of the l eft-hand
si de of the fi gure.
The bl ock di agram of an exampl e usi ng the tool box to bui l d a FDMA system i s
shown i n the fol l owi ng fi gure. Thi s exampl e uses the DSB-SC AM modul ati on
method.
Input 1
Input 2
Input 3
Time
Modulate to
frequency f2
Time
f1
f2
f3
Demod with
frequency f1
Demod with
frequency f2
Demod with
frequency f3
&
bandpass filt
[f2-B, f2+B]
Modulate to
frequency f1
&
bandpass filt
[f1-B, f1+B]
Modulate to
frequency f2
&
bandpass filt
[f3-B, f3+B]
bandpass filt
[f1-B, f1+B]
&
&
bandpass filt
[f2-B, f2+B]
&
bandpass filt
[f3-B, f3+B]
F
r
e
q
u
e
n
c
y
A
m
p
l
i
t
u
d
e
A
m
p
l
i
t
u
d
e
A
m
p
l
i
t
u
d
e
3-110
Figure 3-24: Simulink Block Diagram FDMA Example
The detai l ed di scussi on of the FDMA bl ock di agram i s provi ded i n the
Si mul i nk Bl ock Refer ence chapter .
Code Division Multiple Access (CDMA)
CDMA i s wi del y used i n moder n communi cati on systems, such as wi r el ess
communi cati on systems. There are a number of CDMA methods used i n
appl i cati ons. Thi s tool box pr ovi des a frequency hoppi ng CDMA as an exampl e
of how to use the tool box to i mpl ement a CDMA communi cati on system. For
more i nfor mati on about CDMA and fr equency hoppi ng methods, refer to Skl ar ,
Digital Communications, Fundamentals and Applications, p. 491-3.
A fr equency hoppi ng CDMA uses the vector r e-di stri butor di scussed i n the
TDMA secti on. The fol l owi ng bl ock di agram shows a si mpl e fr equency hoppi ng
CDMA system exampl e.
.
.
AWGN
channel
+
+
+
DSBSC
AM
DSBSC
AM
DSBSC
AM
Costas PLL
DSB ADM
Costas PLL
DSB ADM
Costas PLL
DSB ADM
Mux
FDMA Mux FDMA Demux
Mux
AWGN
channel
Vector
pulse
Time
delay
.
Vector
redistributor
FDMA
demux
.
Vector
redistributor
FDMA
mux
CDMA mux
CDMA demux
3-111
The frequency hoppi ng CDMA pr ocess r earr anges the i nput vector si gnal , then,
the rear ranged si gnal vector goes thr ough the FDMA process. The r ecovery of
the CMDA si gnal i s the i nver se pr ocess of the CDMA process.
The ti me-frequency di str i buti on map of the frequency hoppi ng CDMA Mux for
thi s exampl e i s shown i n the fol l owi ng fi gure. Three si gnal s are mi xed wi th
ti me, and then the mi xed si gnal s ar e modul ated to di ffer ent frequenci es. The
ti me-frequency shar i ng map rel ated to the or i gi nal si gnal i s shown on the
ri ght-hand si de of the fi gur e. The CDMA Demux i s the exact rever se of the fl ow
wi th the consi derati on of the ti me del ay.
Figure 3-25: CDMA Example
Pl ease read the Si mul i nk reference for the Si mul i nk si mul ati on r esul t by usi ng
the exampl e.
Input 1
Input 2
Input 3
Time Domain Signal
f1
f2
f3
Vector
Redis-
tribution
t0 t2 t1 t3 t4
t0 t2 t1 t3 t4
t0 t2 t1 t3 t4
frequency
time
Time Domain Signal
Trigger signal
t0 t2 t1 t3 t4
Modulate to
frequency f2
&
bandpass filt
[f2-B, f2+B]
Modulate to
frequency f1
&
bandpass filt
[f1-B, f1+B]
Modulate to
frequency f2
&
bandpass filt
[f3-B, f3+B]
3-112
Transmitting and Receiving Filters
There ar e a number of fi l ter s speci al l y desi gned for communi cati on systems.
Thi s secti on di scusses these fi l ters. The fi l ter s di scussed i n thi s secti on i ncl ude
the rai sed cosi ne fi l ter, si nc fi l ter, Hi l bert tr ansfor m fi l ter, and compl ex fi l ter.
These fi l ters ar e mostl y used i n the tr ansmi tti ng and recei vi ng front. The
commonl y used di gi tal fi l ter s such as the l owpass fi l ters, hi ghpass fi l ter s,
bandpass fi l ter s, and bandstop fi l ters can be found i n the DSP Bl ockset, whi ch
i s another product i n the MATLAB pr oduct fami l y.
Di ffer ent desi gn methods ar e avai l abl e i n the functi on bl ocks, such as
Butterwor th fi l ter, Chebychev fi l ter (type I and type I I ), and El l i pti c fi l ter, etc.
Raised Cosine Filter
The transfer functi on of the rai sed cosi ne fi l ter i s
where r i s the rol l off factor and T i s the ti me i nterval of the di gi tal message.
After a di gi tal si gnal passes a R-C fi l ter , the frequency of the si gnal i s l i mi ted
i n the band [-W, W], wher e . The fr equency spectrum of the rai sed
H f ( )
T i f 0 f
1 r
2T
----------- -
T
2
--- - 1
T
r
------- f
1 r
2T
----------- -
,
_
,
_
cos + i f
1 r
2T
----------- - f
1 r +
2T
------------
0 i f
1 r +
2T
------------ f

'

=
W
1
2T
------- >
3-113
cosi ne fi l ter i s shown i n the fol l owi ng pl ot.
The ti me r esponse of the fi l ter i s:
r 0 r r 0 r
0
T
h t ( )
si nc
t
T
----
,
_

rt
T
--------
,
_
cos
1 4
r
2
t
2
T
2
---------- -
---------------------------------------------- =
3-114
Thi s fi gur e shows the ti me domai n i mpul se and frequency responses of the R-C
fi l ter (for r=0, 0.5, 1) i n the upper and l ower pl ots r especti vel y:.
Note that T has been nor mal i zed to 1 i n these gr aphs. When the i nput i s a step
si gnal or a conti nuous si gnal , a si nc fi l ter shoul d be used befor e usi ng the
rai sed cosi ne fi l ter. The si nc fi l ter i s di scussed i n the next secti on.
The rai sed cosi ne fi l ter i s a non-causal fi l ter . The i mpl ementati on of a
non-casual fi l ter i s i mpossi bl e because a non-causal fi l ter depends on futur e
i nput i nformati on. To sol ve thi s probl em, thi s tool box has arti fi ci al l y added a
ti me del ay to the fi l ter i n the i mpl ementati on. The ti me del ay i s usual l y T
mul ti pl i ed by a posi ti ve i nteger .
I n some appl i cati ons, a r ai sed cosi ne fi l ter can be di vi ded i nto two par ts, one
for the tr ansmi tti ng si de and one for the r ecei vi ng si de. I n thi s case, each si de
3 2 1 0 1 2 3
0.5
0
0.5
1
r = 0
r = 0.5
r = 1
Time Response
1 0.8 0.6 0.4 0.2 0 0.2 0.4 0.6 0.8 1
0
0.5
1
Frequency Response
r = 0
r = 0.5
r = 1
3-115
has the squar e r oot of the rai sed cosi ne fi l ter. The i mpul se r esponse of a
square-r oot R-C fi l ter i s:
I n usi ng the squar e r oot rai sed cosi ne fi l ter, the si nc fi l ter shoul d be used on
the tr ansmi tti ng si de but not on the recei vi ng si de. The combi nati on of two
square root rai sed cosi ne fi l ters i n thi s way i s equi val ent to a nor mal rai sed
cosi ne fi l ter i f there i s no channel noi se and di stor ti on.
Ra i sed Cosi ne Fi lter Ex a mple
Thi s exampl e shows how to use the rai sed cosi ne fi l ter. You can r un thi s
exampl e by typi ng t s t r c os 2 i n the command wi ndow. The fi gur e bel ow shows
the bl ock di agr am of the Si mul i nk exampl e:
The sampl i ng ti me i s .1 sec. A pul se wi th wi dth equal to 1 sec i s gener ated from
the Sampl ed Read Workspace bl ock. The si gnal i s sent to four di fferent setups
h t ( )
4r
T
-----------
1 r + ( )
t
T
----
,
_
cos
1 r ( )
t
T
--- -
,
_
si n
4r
t
T
----
--------------------------------------- +
1 4r
t
T
----
,
_
2

,
_
------------------------------------------------------------------------------------- =
3-116
of the R-C fi l ter s. I n al l R-C fi l ter s, the di gi tal tr ansfer ri ng sampl i ng ti me i s set
to be 1, computati on sampl i ng ti me i s .1, fi l ter r ol l off factor i s .5, and fi l ter type
i s FI R. The fi r st row of the R-C fi l ter uses the si nc fi l ter. The del ay step i s 6.
The second row of the R-C fi l ter does not use the si nc fi l ter i n the R-C fi l ter
par ameter setup; i t uses an external si nc fi l ter. The l eft pl ot i n the fi gur e bel ow
shows the si mul ati on r esul t of the fi rst and the second r ow. These two r esul ts
overl ap each other perfectl y.
The thi r d r ow uses two FI R/s r qt fi l ter s. The fi rst R-C fi l ter uses a si nc fi l ter
and the second R-C fi l ter does not use a si nc fi l ter. The del ay step for each bl ock
i s 3. The mi ddl e pl ot i n the fi gure bel ow shows the si mul ati on resul t. Thi s
si mul ati on resul t i s al most the same as when usi ng a si ngl e nor mal R-C fi l ter.
The fourth r ow uses no si nc fi l ter . I n the fi gur e bel ow, the ri ght pl ot shows the
si mul ati on r esul t. Note the ampl i tude of the si mul ati on r esul t i s much l ar ger
compar ed to the other si mul ati on r esul ts.
0 2 4 6 8 10 12
0
0.2
0.4
0.6
0.8
1
Time (second)
0 2 4 6 8 10 12
0
0.2
0.4
0.6
0.8
1
Time (second)
0 2 4 6 8 10 12
0
1
2
3
4
5
6
7
8
9
10
Time (second)
3-117
An FFT scope (thi s scope i s pr ovi ded i n the DSP Bl ockset) i s used to anal yze
the spectrum of the r esul t i n the fi rst r ow. The si mul ati on spectrum matches
the theor eti cal spectrum.
Sinc Filter
The transfer functi on of the i nver se si nc fi l ter i s a si nc functi on
The ti me domai n i mpul se response of thi s fi l ter i s an sampl e-ti me-uni t wi dth
i mpul se. Thi s bl ock i s often used i n conjuncti on wi th the r ai sed cosi ne fi l ter .
Hilbert Transform Filter
The Hi l bert tr ansfor m fi l ter outputs a -90
o
phase shi fted si gnal over the i nput
si gnal . The Hi l ber t transform fi l ter has the transfer functi on
0 0.5 1 1.5
0
2
4
6
8
10
12
M
a
g
n
i
t
u
d
e
Frequency (Hz)
si nc f ( )
f ( ) si n
f
------------------- t 0
1 t 0 =

'

=
H f ( ) j f ( ) sgn =
3-118
whi ch has the i mpul se r esponse
The Hi l ber t transfor m fi l ter s are used i n SSB AM modul ati ons.
The Hi l bert transform fi l ter i s a noncausal fi l ter. Thi s means that the curr ent
output depends on the futur e i nput of the system. The transfer functi on
contai ns a purel y i magi nar y component, whi ch means the i mpul se response of
the fi l ter i s odd symmetr i c. The i mpul se response of the system i s depi cted on
the l eft-hand si de pl ot of the fi gure.
The fi l ter i s not real i zabl e si nce i ts i mpul se response i s not zero pri or to the
ti me zero poi nt. To over come thi s di ffi cul ty, an ar ti fi ci al del ay i s added to the
fi l ter desi gn. The del ay i s added such that the val ue of the i mpul se response
before the ti me zer o i s not si gni fi cant and i s i gnor ed i n the i mpl ementati on.
The i mpul se response of a del ayed Hi l bert tr ansfor m fi l ter i s shown on the
ri ght-hand si de pl ot of the above fi gur e.
h t ( )
1
t
----- =
(a) impulse response of HTF (b) impulse response of delayed HTF
time
delay
3-119
Channels
Communi cati on channel s i ntr oduce noi se, fadi ng, i nterfer ence, etc., i nto the
tr ansmi tti ng si gnal s. I n communi cati on system si mul ati on, the model i ng of a
channel i s based on mathemati cal descr i pti ons of the channel . The channel
model s di ffer from one tr ansmi tti ng medi a to another . Thi s tool box pr ovi des a
l i mi ted number of tr ansmi tti ng channel model s. You are encour aged to
constr uct your own channel model s. I f the channel model i s l i near, you can use
the functi ons i n the System I denti fi cati on Tool box to i denti fy the structure of
the channel . I f the channel model i s non-l i near , you can use the Opti mi zati on
Tool box to sear ch for the par ameters wi th measur ement data and the gi ven
str uctur e of the model .
The tool box i ncl udes two di ffer ent ki nds of channel model s: passband and
baseband. The most commonl y used model i n channel si mul ati on i s the AWGN
(addi ti ve whi te Gaussi an noi se) model .
I n gener al , the channel model can be used di r ectl y i n connecti ng the
tr ansmi tti ng si de and the recei vi ng si de of a communi cati on system as shown
i n thi s fi gur e:
Passband Channels
I n passband channel s, the transmi tti ng si gnal i s assumed to be a scal ar si gnal .
The passband channel subl i br ary of thi s tool box i ncl udes an AWGN channel
model and a bi nary er ror channel model . Thi s fi gur e shows an addi ti ve noi se
channel model :
An AWGN model i s a channel wi th whi te Gaussi an noi se as the noi se sour ce.
Gaussi an noi se i s di scussed i n the Si gnal Generator s and Di spl ay Devi ces
secti on of thi s chapter.
Channel Recei ver Transmi tter
Noi se
source
Transmi tti ng si gnal
Recei vi ng si gnal
+
3-120
The channel fadi ng model i n the passband si mul ati on i s si mpl y the
tr ansmi tti ng si gnal mul ti pl y a gai n val ue. The gai n i s l ess than or equal to one.
You can use the MATLAB functi on r and to gener ate uni form di stri buti on noi se
and r andn to gener ate Gaussi an noi se. The Stati sti cs Tool box suppor ts more
choi ces for noi se gener ator functi ons as wel l .
Baseband Channels
Baseband channel model s have the same channel model str uctur e as di scussed
i n the passband channel . The transmi tti ng si gnal , recei vi ng si gnal , and the
noi se sour ce are compl ex. The real part of the si gnal i s the i n-phase component
and the i magi nar y par t of the si gnal i s the quadr atur e component. I n Si mul i nk
bl ocks, a compl ex si gnal i s represented by a two el ement vector. The fi rst
el ement i s the r eal (i n-phase) component. The second el ement i s the i magi nary
(quadr ature) component.
Ra yleigh N oi se Cha nnel
The noi se i nput source for the Rayl ei gh noi se channel i s the Rayl ei gh noi se.
The noi se sour ce i s di scussed i n the Si gnal Gener ator s and Di spl ay Devi ces
secti on. I n the channel , two i ndependent zero mean whi te Gaussi an noi ses are
added to the r eal part and the i magi nary part of the transfer red si gnal . These
two i ndependent whi te Gaussi an noi ses shar e a same common var i ance.
Ri ci a n N oise Cha nnel
The addi ti ve noi se source for the Ri ci an noi se channel i s a Ri ci an noi se. I n the
channel , two i ndependent Gaussi an noi ses are added to the real -par t and
i magi nar y part of the transferr ed si gnal . These two i ndependent Gaussi an
noi ses shar e a same mean val ue and a same common vari ance. For a di scussi on
of the Ri ci an channel , see Webb and Hanzo, Modern Quadrature Amplitude
Modulation, p.61.
Fa ding Cha nnel
The fadi ng channel i n the baseband si gnal tr ansmi ssi on has the fol l owi ng form
where u(t) i s the tr ansfer ri ng si gnal ; y(t) i s the output of the channel ; (t) i s the
fadi ng envel ope and (t) i s the phase shi ft i n radi ans. When both (t) and (t)
ar e ti me i nvari ant, the fadi ng channel has a fi xed form.
y t ( ) u t ( ) t ( ) j t ( ) ( ) exp =
3-121
Synchronization
The communi cati on recei vers have to be synchroni zed wi th the transmi tter s i n
order to make a cor rect tr ansmi ssi on. The si mul ati on of the synchroni zati on i s
a ti mi ng si mul ati on. The synchroni zati on functi onal i ty i s pr ovi ded i n the
Si mul i nk bl ock l i brary onl y. The Communi cati on Tool box provi des the Phase
Locked Loop (PLL) synchroni zati on si mul ati on. A di gi tal earl y-l ate gate
si mul ati on i s pr ovi ded as an exampl e i n the next chapter.
A PLL i s an automati c control system to adjust the phase of the l ocal
si gnal to match the phase the phase of the r ecei ved
si gnal . I n the PLL desi gn, i t i s assumed that the phase
i s sl owl y var yi ng wi th r espect to the fr equency .
Passband Signal PLL Simulation
A typi cal PLL consi sts of thr ee components: a phase detector , a fi l ter H(s), and
a VCO (vol tage control l ed osci l l ator). The phase detector i n a si mpl e PLL i s a
mul ti pl i er. The str ucture of a si mpl e PLL i s shown i n the fol l owi ng fi gure.
I n the fi gure, i s the i ncomi ng si gnal and
i s a l ocal l y generated si gnal . Note that has
been added to the VCO as an i ni ti al val ue of the phase shi ft. I n thi s tool box, a
mul ti pl i er phase detector i s used. The output of the mul ti pl i er , x(t), i s
. After passi ng a l ow-pass
fi l ter H(s), the hi gh frequency term, the second ter m i n the equati on, i s fi l ter ed.
The si gnal e(t) i s . When i s smal l , we have
. Note that the PLL fai l s when the devi ati on of i s cl ose to
.

t ( )
s

t ( ) 2f
c
t

t ( ) + ( ) si n = t ( )
s t ( ) 2f
c
t t ( ) + ( ) si n =
t ( ) f
c
H(s)
VCO
s t ( )
s t ( )
x t ( ) e t ( )
Phase
Detector
s t ( ) 2f
0
t t ( ) + ( ) si n =
s

t ( ) 2f
0
t

t ( )

2
--- + +
,
_
si n = 2
t ( )
1
2
--- t ( )

t ( ) [ ] si n
1
2
--- 2f
0
t + t ( )

t ( ) [ si n + =
e t ( )
1
2
--- t ( )

t ( ) [ ] si n = t ( )

t ( )
e t ( ) t ( )

t ( ) = t ( )
2
3-122
H(s) i s a l owpass fi l ter . You may use the MATLAB functi on pl l f i l t to desi gn
the fi l ter .
The baseband model PLL method uses the mul ti pl i er phase detector and
rear rangi ng the vari abl es, the PLL i n the fol l owi ng fi gure i s equi val ent to the
previ ous PLL descr i bed above.
The baseband model for the PLL i s a nonl i near system model . The model
depends on the i nformati on of the ampl i tude A
c
of the i ncomi ng si gnal . The
model i s i ndependent of the carr i er fr equency f
0
.
The baseband model for the PLL i s a nonl i near system. I t i s di ffi cul t to anal yze
a nonl i near system. Usi ng the approxi mati on when
i s smal l , a l i near i zed Baseband Model PLL bl ock resul ts, whi ch i s
the si mpl est PLL model , as shown i n the fol l owi ng fi gure.
The transfer functi on fr om the i nput phase to phase err or i s
. A PLL wi thout fi l ter i s a fi r st or der PLL. A PLL wi th
(n-1)th or der H(s) i s an nth or der PLL. I t i s known that the steady state phase
err or i s zero for a rati onal H(s). You can use the MATLAB Contr ol System
Tool box to desi gn and to anal yze the PLL systems.
So far , al l PLLs di scussed above ar e anal og. The char ge pump PLL i s a cl assi cal
di gi tal PLL. I n the above di scussi on, a mul ti pl i er i s used as phase detector. I n
practi ce, a number of other phase detectors can be used. One of them i s the
sequenti al l ogi c phase detector . A PLL wi th a sequenti al l ogi c phase detector
(al so named di gi tal phase detector) i s known as char ge pump PLL.
H(s) + A
c
. ( ) si n
s t ( ) t ( )
s t ( )
K
-
1
s
---
t ( )

t ( ) [ ] n t ( )

t (
t ( )

t ( )
H(s) +
1
s
---
A
c
K
s t ( ) t ( )
s t ( )
-
s t ( ) t ( )
G s ( )
s
s A
c
KH s ( ) +
--------------------------------- =
t ( )
3-123
A sequenti al l ogi c phase detector oper ates on the zer o crossi ngs of the si gnal
wavefor m. The equi l i bri um poi nt of the phase di ffer ence between the i nput
si gnal and the VCO si gnal equal s . The sequenti al l ogi c detector can
compensate for any fr equency di ffer ence that mi ght exi st between a VCO and
an i ncomi ng si gnal fr equency. Hence, the sequenti al l ogi c phase detector acts
as a fr equency detector . For thi s r eason, a sequenti al l ogi c phase detector i s
al so cal l ed a phase/frequency detector (PFD).
A di scussi on of the charge pump PLL can be found i n [40]. Ther e ar e other
references for the charge pump phase-l ocked l oop, such as [17] and [18].
Baseband Signal PLL Simulation
Si mul ati on usi ng the baseband wavefor m has been di scussed. PLL i s one of the
keys i n the demodul ati on. The si mul ati on of PLL can be on the baseband
wavefor m. I n thi s case, the si mul ati on can be at a l ower sampl e r ate than that
requi red to match the carr i er frequency. The baseband waveform si mul ati on
for PLL can be done by usi ng the str uctur e shown i n the fol l owi ng fi gure.
Pl ease note that al though the si mul ati on of the baseband wavefor m PLL can
have i ts si mul ati on sampl e rate much l ower than the carr i er fr equency f
c
, to be
abl e to fi nd the accurate del ay, the si mul ati on step si ze shoul d be smal l
enough.
H(s) Imag(.) x
1/s K exp(.)
-j
Y(t)=A exp(j(t))
(t) K exp(-j(t))
A K sin((t)-(t))
^
FM
PM
^
^
3-124
Utilities
Thi s tool box i ncl udes a number of basi c functi ons and bl ocks to support the
functi ons descr i bed i n the pr evi ous secti ons. Pl ease see the Si mul i nk r efer ence
for detai l ed di scussi on on each of the functi ons. Thi s secti on l i sts al l functi ons.
Sel ected functi ons are di scussed i n more detai l whi l e other s are ski pped
because thei r functi onal i ty i s obvi ous.
Vol tage Contr ol l ed Osci l l ator
Modul o I ntegr ator
Wi ndowed I ntegr ator
Schedul ed I ntegr ator
Envel op Detector (not di scussed)
Edge Detector (not di scussed)
Regi ster Shi ft (not di scussed)
Tr i ggered Buffer Down (not di scussed)
Vector Redi stri buti on (not di scussed)
Number Counter (not di scussed)
Err or Counter (not di scussed)
Mi ni mum/Maxi mum I ndex
Arr ay Functi ons
Scal ar to Vector Conver ter
Vector to Scal ar Conver ter
Modul o Operati on
Mean and Var i ance
Compl ex Fi l ter (not di scussed)
K-Step Del ay (not di scussed)
3-125
Voltage Controlled Oscillator
The functi onal i ty of the vol tage control l ed osci l l ator (VCO) i s the same as the
frequency modul ati on. The vol tage of the i nput si gnal m(t) control s the
osci l l ati on fr equency of the output si gnal y(t).
where y(t) i s the modul ated si gnal . f
c
i s the car ri er frequency. The uni t for f
c
i s
Her tz.
c
i s the i ni ti al phase. The uni t for
c
i s r adi ans. (t) i s the modul ati on
phase, whi ch i s the i ntegr ati on of the i nput si gnal m(t).
I n the equati on, k
c
i s the sensi ti vi ty factor .
Modulo Integrator
Si mul i nk can be used for both conti nuous-ti me and di screte-ti me system
si mul ati on. I n conti nuous-ti me system si mul ati on, the step si ze reduces i f the
computati on err or i s l ar ger than the gi ven tol er ance. The computati on err or i s
determi ned by the r el ati ve err or i n the i ntegrati on computati on. I n a
si mul ati on system, i f one i ntegr ati on val ue i s getti ng much l ar ger than the
other s, that i ntegrati on val ue wi l l pl ay a domi nant rol e i n the computati on
tol erance eval uati on. I n some appl i cati ons, the modul o of the i ntegr ati on val ue
i s used i nstead of i ts ori gi nal val ue.
One appl i cati on i s the computati on of the FM modul ati on. The modul ated
si gnal y(t) i s
where (t) i s the modul ati on phase, whi ch changes wi th the ampl i tude of the
i nput m(t) i n the for m
I f the i nput val ue m(t) keeps the same val ue, the val ue (t) can be ver y l arge.
However, onl y (t) modul o one i s used i n the output computati on. Thi s
i ntegrati on outputs the val ue of the modul o i ntegr ati on.
y t ( ) m t ( ) 2f
c
t 2 t ( )
c
+ + ( ) cos =
t ( ) k
c
m t ( )dt
0
t

=
y t ( ) 2f
c
t 2 t ( )
c
+ + ( ) cos =
t ( ) k
c
m t ( )dt
0
t

=
3-126
Windowed Integrator
For an i nput si gnal u(t), the output of the wi ndowed i ntegrator i s
where T i s a posi ti ve number , whi ch i s the i ntegrati on wi ndow si ze of the
i ntegrator. I n the computati on, u(t)=0, for t<0 i s assumed.
Scheduled Reset Integrator
Gi ven an i nput si gnal u(t), the output of the schedul ed r eset i ntegrator i n the
ti me i nter val i s
where T i s a posi ti ve number , whi ch i s the reset schedul e i nter val .
Minimum/ Maximum Index
Thi s bl ock has been used i n the M-ary FSK demodul ati on bl ock. The
functi onal i ty of thi s bl ock i s to output the i ndex of the el ement wi th i ts val ue
havi ng the maxi mum val ue (or mi ni mum val ue).
Array Functions
Some bl ocks i n the curr ent Si mul i nk bl ock l i brar y can be used onl y for scal ar
i nput or scal ar output. An ar ray functi on bl ock has been added for mul ti pl e
i nput/mul ti pl e output functi ons. Thi s bl ock i s l i mi ted to cal cul ate the functi ons
wi th the i nput and output vector s havi ng exactl y the same si ze. Some functi ons
that can be cal cul ated usi ng thi s bl ock i ncl ude: s i n, c os , t an, e x p, l og, l n, etc.
Scalar to Vector Converter
Thi s functi on converts scal ar i nteger symbol s to bi nar y (base 2) vectors. The
functi on de 2bi i s desi gned for thi s usage. A Scal ar to vector conver ter bl ock i n
Si mul i nk has the same functi onal i ty.
y t ( ) u ( )d
t T
t

=
nT t < n 1 + ( )T
y t ( ) u ( )d
t nT
t

=
3-127
Vector to Scalar Converter
Thi s functi on conver ts bi nary (base 2) vector s to i nteger scal ar number s. The
functi on bi 2de i s desi gned for the usage. A Vector to scal ar converter bl ock i n
Si mul i nk has the same functi onal i ty.
Modulo Operation
The modul o oper ati on i n MALTAB i s an i nternal functi on r e m. I n the Si mul i nk
bl ock l i br ary, a si mi l ar functi onal i ty i s i mpl emented.
Mean and Variance
I n MATLAB, you can use functi ons me an and s t d for the mean and var i ance
cal cul ati ons. I n the Si mul i nk bl ock l i brary, a bl ock i s i mpl emented to cal cul ate
the mean and vari ance of al l of the past i nput val ues of the si gnal .
3-128
Galois Field Calculations
Thi s tool box provi des a set of sel f-contai ned Gal oi s fi el d functi ons to support
err or-control codi ng and decodi ng. Thi s secti on di scusses the defi ni ti on of
Gal oi s fi el ds and the ar i thmeti c and al gebrai c computati ons i n these fi el ds.
Galois Field, GF(q)
A fi ni te fi el d, that i s, a fi el d contai ni ng a fi ni te number of el ements, i s cal l ed a
Galois field. The notati on for a Gal oi s fi el d i s GF(q) where q=p
M
. The
par ameter p must be a pri me number, and M must be a posi ti ve i nteger . For
i nstance, there i s no fi ni te fi el d contai ni ng 24 el ements. I f q=p (i .e., M=1), then
GF(q) i s known as a prime field. I f M>1, then GF(q) i s cal l ed an extension field.
Addi ti on and mul ti pl i cati on i n a pri me fi el d ar e equi val ent to the
cor respondi ng modul o-p operati ons on i ntegers, but thi s i s not true for
extensi on fi el ds. As an exampl e of addi ti on i n a pr i me fi el d, thi s tabl e l i sts al l
the possi bl e addi ti on cal cul ati ons i n GF(5):
Thi s tabl e l i sts al l the mul ti pl i cati ons possi bl e i n GF(5):
+ 0 1 2 3 4
0 0 1 2 3 4
1 1 2 3 4 0
2 2 3 4 0 1
3 3 4 0 1 2
4 4 0 1 2 3
* 0 1 2 3 4
0 0 0 0 0 0
1 0 1 2 3 4
2 0 2 4 1 3
3 0 3 1 4 2
4 0 4 3 2 1
3-129
You can per form addi ti on i n pri me and extensi on fi el ds by usi ng the functi on
gf add. Mul ti pl i cati ve i n pri me and extensi on fi el ds can be done by usi ng
functi on gf mul . You can constr uct the above addi ti on and mul ti pl i cati on tabl es
by usi ng the fol l owi ng commands:
q = 5;
gf _q_add = [ ] ; % As s i gn a v ar i abl e name f or addi t i on t abl e .
gf _q_mul = [ ] ; % As s i gn a v ar i abl e name f or mul t i pl i c at i on t abl e.
f or i = 0: q- 1
gf _q_add = [ gf _q_add; gf add( i *one s ( 1, q) , [ 0: q- 1] , q) ] ;
% Cons t r uc t t he addi t i on t abl e .
gf _q_mul = [ gf _q_mul ; gf mul ( i *one s ( 1, q) , [ 0: q- 1] , q) ] ;
% Cons t r uc t t he mul t i pl i c at i on t abl e .
e nd;
By changi ng the val ue of q, you can construct a tabl e for any pr i me number.
Di vi si on and subtr acti on i n pr i me and extensi on fi el ds can be done by usi ng the
commands gf di v and gf s ub r especti vel y.
GF(2) i s a speci al Gal oi s fi el d, the binary Galois field. Most er ror -contr ol codi ng
al gor i thms ar e constr ucted usi ng GF(2). I n GF(2), there ar e onl y two el ements:
0 and 1 .
Polynomials over GF(q)
A pol ynomi al over GF(q) i s a pol ynomi al whose coeffi ci ents are el ements fr om
GF(q). Thi s tool box uses a vector to represent a pol ynomi al . The ascendi ng
ordered for mat i s used i n repr esenti ng a pol ynomi al . For i nstance, a
pol ynomi al over GF(q)
i s r epr esented by a vector . Functi on gf pr e t t y i s desi gned
to i mprove the vi sual presentati on of al gebrai c equati ons. For exampl e,
x = [ 1 2 3 4 5 4 3 2 1] ;
gf pr e t t y( x)
ans =
2 3 4 5 6 7 8
1 + 2 X + 3 X + 4 X + 5 X + 4 X + 3 X + 2 X + X
f X ( ) g
0
g
1
X g
2
X
2
g
3
X
3
... g
M
X
M
+ + + + + =
g
0
g
1
g
2
g
3
... g
M
3-130
The degree of a pol ynomi al i s defi ned to be the hi ghest exponent val ue of X i n
f(X). The above exampl e f(x) has degree 8. You can add two pol ynomi al s by
di rectl y usi ng gf add. The mul ti pl i cati on of two pol ynomi al s (convol uti on) can
be done by usi ng gf conv . The di vi si on of one pol ynomi al by another
(deconvol uti on) i n GF(q) can be done by usi ng gf dec onv. For exampl e, to
mul ti pl y pol ynomi al x = [1 1 1 1 1] by pol ynomi al y = [1 1 1 1 1] over GF(7), use
the command
z = gf c onv ( x , y, 7)
whi ch r esul ts i n z = [1 2 3 4 5 4 3 2 1] i n GF(7). The fol l owi ng functi ons ar e
speci al l y desi gned for pol ynomi al computati on i n GF(q) or GF(q
M
):
gf add, gf c onv, gf de conv , gf pr i mc k, gf pr i mdf , gf pr i mf d
The l ast three functi ons on the l i st ar e desi gned for pr i mi ti ve pol ynomi al
computati on. Thi s concept i s di scussed i n the next secti on, GF(q
M
), the GF(q)
Fi el d Extensi on.
Pol ynomi al s over GF(2) ar e the most commonl y used i n err or-contr ol codi ng.
The pol ynomi al functi ons l i sted above use GF(2) as the defaul t i f the pr i me
number q i s not speci fi ed.
GF(q
M
), the GF(q) Field Extension
The el ements of an extensi on fi el d, GF(q
M
), of a pri me fi el d GF(q) can be
conveni entl y repr esented by pol ynomi al s of degree M-1 and coeffi ci ents i n
GF(q). Al l el ements of GF(q
M
) can be gener ated by constructi ng pol ynomi al s of
degr ee M-1 wi th al l q
M
possi bl e combi nati ons of coeffi ci ents i n GF(q). Addi ti on
and subtr acti on of two pol ynomi al s over GF(q) ar e perfor med by si mpl y
performi ng those operati ons on the corr espondi ng coeffi ci ents.
Deter mi ni ng the rul es for mul ti pl i cati on i s more compl i cated and requi res
some addi ti onal defi ni ti ons. A pr i mi ti ve el ement, , of GF(q) has the property
that al l nonzer o el ements of the fi el d can be gener ated by for mi ng successi ve
powers of . Every Gal oi s fi el d has at l east one pri mi ti ve el ement. A degr ee-M
pol ynomi al wi th coeffi ci ent i n GF(q) i s sai d to be irreducible i f i t i s not di vi si bl e
by any pol ynomi al wi th coeffi ci ents i n GF(q) and of degree l ess than M and
gr eater than zero. An i r reduci bl e pol ynomi al havi ng a pr i mi ti ve el ement i s
known as a primitive polynomial.
3-131
Mul ti pl i cati on of pol ynomi al s i s done i n the customar y manner except for the
fact that powers that become too hi gh for the extended Gal oi s fi el d are r educed
by means of a pr i mi ti ve pol ynomi al set equal to zer o. I f p(X) i s a pr i mi ti ve
pol ynomi al for the extensi on fi el d, then we can use the r el ati onshi p
p(X) = a
0
+a
1
X + a
2
X
2
+... +X
M
or
X
N
=a
0
a
1
X a
2
X
2
... a
M-1
X
M-1
Note that for an el ement a i n the bi nar y fi el d
a = a
Mul ti pl i cati on tabl es for el ements of an extended Gal oi s fi el d can be generated
by the use of a pr i mi ti ve pol ynomi al . Note that a speci fi c pri mi ti ve pol ynomi al
i s associ ated wi th the tabl e.
A l i st of al l el ements i n a GF(q
M
) can be gener ated by usi ng functi on gf t upl e.
For exampl e, a l i st of GF(3
3
) can be gener ated by the fol l owi ng commands:
% s pe ci f y t he ex pone nt i al v al ue M and pr i me numbe r q
M = 3; q = 3;
% gener at e a l i s t of GF( q^M) t upl e f or m i n t upl e
% and e xpone nt i al f or m i n pow.
[ t upl e, pow] = gf t upl e( [ - 1: q^M- 2] ' , M, q)
3-132
There ar e thr ee di fferent ki nds of representati ons for the el ements i n GF(q
M
),
the exponenti al repr esentati on, the M-tupl e r epr esentati on, and the
pol ynomi al r epresentati on. Thi s i s a l i st of al l the el ements i n GF(3
3
):
Exponential 3-Tuple Polynomial
[ 0 0 0] 0
[ 1 0 0] 1
[ 0 1 0] X
[ 0 0 1] X
2
[ 2 1 0] 2 + X
[ 0 2 1] 2X + X
2
[ 2 1 2] 2 + X + 2X
2
[ 1 1 1] 1 + X + X
2
[ 2 2 1] 2 + 2X + X
2
[ 2 0 2] 2 + 2X
2
[ 1 1 0] 1 + X
[ 0 1 1] X + X
2
[ 2 1 1] 2 + X + X
2
[ 2 0 1] 2 + X
2
[ 2 0 0] 2
[ 0 2 0] 2X
[ 0 0 2] 2X
2
[ 1 2 0] 1 + 2X
[ 0 1 2] X + 2X
2
[ 1 2 1] 1 + 2X + X
2


0 =

0
1 =

10

11

12

13

14

15

16

17

18
3-133
For conveni ence, thi s tool box uses the exponent of to repr esent the el ement
i n GF(q
M
). For exampl e, the tabl e uses x=9 to represent . By conventi on,
i s r epresented by any negati ve i nteger . You can use functi on gf t upl e to conver t
a vector of exponenti al for m to M-tupl e form.
The extensi on fi el d GF(q
M
) possesses many i nter esti ng mathemati cal
properti es. Cal cul ati ons ar e not as str ai ghtforward i n GF(q
M
) as i n GF(q). The
Communi cati ons Tool box supports a number of cal cul ati ons on GF(q
M
),
i ncl udi ng:
Addi ti on i n GF(q
M
)
Mul ti pl i cati on i n GF(q
M
)
Cycl otomi c coset cal cul ati on i n GF(q
M
)
Mi ni mal Pol ynomi al s over GF(q
M
)
The Roots of Pol ynomi al s over GF(q
M
)
Vari ous uti l i ti es, such as pol ynomi al tr uncati on
The fol l owi ng secti ons of thi s chapter di scuss each of these topi cs i n turn.
[ 2 2 2] 2 + 2X + 2X
2
[ 1 1 2] 1 + X + 2X
2
[ 1 0 1] 1 + X
2
[ 2 2 0] 2 + 2X
[ 0 2 2] 2X + 2X
2
[ 1 2 2] 1 + 2X + 2X
2
[ 1 0 2] 1 + 2X
2
Exponential 3-Tuple Polynomial

19

20

21

22

23

24

25


3-134
Addi ti on in GF(q
M
)
Addi ti on i n GF(q
M
) can be done as an el ement-by-el ement modul o-q cal cul ati on
on M-tupl e vectors. Star ti ng fr om the exponenti al r epr esentati on, the
cal cul ati on i s shown i n thi s fl ow chart:
You can use gf add or gf pl us for the GF(q
M
) cal cul ati on. A speci al var i abl e t p
shoul d be created as the thi rd par ameter i n the functi on cal l . t p must contai n
al l the el ements i n GF(q
M
). Addi ti on i s defi ned between two el ements i n the
same extensi on fi el d, GF(q
M
).
Thi s i s an exampl e of addi ti on usi ng vectors and
i n GF(3
3
):
% e xponent i al f or m of v ec t or a and b
a = [ 1 3 5 7] ;
b = [ 2 4 6 8] ;
% gener at e GF( 3^3) t upl e l i s t
t p = gf t upl e ( [ - 1: 3^3- 2] ' , 3, 3) ;
% The addi t i ve c al cul at i on
c = gf add( a, b, t p)
c =
You can val i date the r esul t by usi ng the GF(3
3
) el ement l i st tabl e. To veri fy the
addi ti on of
7
pl us
8
cal cul ated above, fi nd from the GF(3
3
) tabl e the 3-tupl e
repr esentati on of
7
and
8
. The repr esentati on for
7
i s [2 2 1], and the
repr esentati on for
8
i s [2 0 2]. The addi ti on of these two el ements i s [1 2 0],
whi ch i s the 3-tupl e representati on of
16
. Thi s r esul t agrees wi th what was
found i n the above cal cul ati on usi ng gf add.
M ultipli ca tion i n GF(q
M
)
Usi ng the exponenti al for m, mul ti pl i cati on i s rel ati vel y si mpl e compar ed to
addi ti on. You need onl y add exponents of modul o-q
M
-1. For exampl e, you can
Element1
Element2
exponential form
to M-tuple form
M-tuple form
(exp)
(exp)
Element1
(M-tuple)
Element2
(M-tuple)
M-tuple element-by-element
Sum
(M-tuple)
Sum
(exp)
+
modulo-q additive calculation
mapping
to exponential
form mapping
a

3

7
=
b

2

8
=
10 12 14 16
3-135
mul ti pl y vector s and usi ng these
commands:
a = [ - I nf 5 15 20] ;
b = [ 1 7 14 21] ;
t p = gf t upl e ( [ - 1: 3^3- 2] , 3, 3) ;
c = gf mul ( a, b, t p) ;
c =
The Cyclotomi c Cosets of GF(q
M
)
Let be an el ement i n GF(q
M
). The el ement
2t
i s cal l ed a conjugate of , where
t i s a posi ti ve i nteger. I t can be shown that for any pol ynomi al f(X) wi th i ts
el ement i n GF(q), i f f() =0, then f(
2t
) =0.
For any i n GF(q
M
), ther e exi sts a subgroup i n a GF(q
M
), cal l ed the cyclotomic
coset associ ated wi th , such that i s cl osed,
i .e., equal s one of the el ements i n the coset as l i sted above. The el ement
wi th the smal l est power number i s cal l ed the leader of the coset. I n the above
exampl e, i s the l eader of the coset. The cycl otomi c cosets can be cal cul ated by
usi ng gf c os et s .
For exampl e, the cosets for GF(2
4
) can be cal cul ated by the command
c s = gf cos e t s ( 4, 2)
c s =
0 NaN NaN NaN
1 2 4 8
3 6 12 9
5 10 NaN NaN
7 14 13 11
The notati on NaN i s used to fi l l the space i n the matri x. Thi s tool box uses
cycl otomi c cosets i n the computati on of mi ni mal pol ynomi al s and for the
computati on of r oots i n GF(q
M
).
M i ni ma l Polynomi a ls over GF(q
M
)
The mi ni mal pol ynomi al of , where i s on GF(q
M
), i s defi ned to be the
pol ynomi al of the smal l est degr ee over GF(q) such that f()=0. I n thi s tool box,
a

I nf

15

20
= b

1

14

21
=
Inf 12 24 10
et cos

2

4
...
2S
=

2 S 1 + ( )
3-136
functi on gf mi npol i s desi gned to fi nd the mi ni mum pol ynomi al . For exampl e,
to fi nd the mi ni mum pol ynomi al of =
3
, where i s i n GF(2
4
), you can si mpl y
use the command
pmi n = gf mi npol y ( 3, 4, 2)
pmi n =
1 1 1 1 1
Usi ng the functi on gf pr e t t y, you can obtai n the pr etty form of pmi n:
gf pr e t t y( gf mi npol y ( 3, 4, 2) )
1 + X + X
2
+ X
3
+ X
4
The Roots of Polynomia ls over GF(q
M
)
The roots of a pol ynomi al f(X) are defi ned to be the sol uti ons of X such that
f(X)=0. A pol ynomi al wi th i ts coeffi ci ents i n GF(q) may have no root i n GF(q).
However, you can fi nd i ts r oots i n an extended fi el d GF(q
M
) by usi ng the
functi on gf r oot s . For exampl e, consi der the pol ynomi al 1 +X + X
2
+X
3
+X
4
over

GF(2).

Nei ther 0 nor 1 i s a sol uti on for thi s pol ynomi al , so i t doesnt have
any sol uti ons i n GF(2). You can fi nd i ts roots i n GF(2
4
) by usi ng functi on
gf r oot s :
a = [ 1 1 1 1 1] ;
r t s = gf r oot s ( a, 4, 2) ' ;
r t s =
3 6 12 9
Other GF(q) Related Functions
There are a number of other functi ons i mpl emented i n thi s tool box to support
the GF(q) computati on. These functi ons are
gf t r unc, whi ch tr uncates an i nput pol ynomi al to el i mi nate usel ess ter ms
gf l i ne q, whi ch sol ves sol ve a l i near equati on i n GF(q) fi el d
3-137
Note that by usi ng MATLAB / or \, you may not be abl e to obtai n a l i near
equati on sol uti on on GF(q). For exampl e:
% Us i ng \ i n MATLAB f i nds s ol ut i ons t hat ar e not i n GF( 3) .
a = [ 0 2 1; 0 2 2; 2 1 0] ;
b = [ 0; 1; 2] ;
x 1 = a \ b
x 1 =
1. 25
- 0. 5
1
% Us e gf l i ne q t o obt ai n c or r e ct s ol ut i ons i n GF( 3) .
x 2 = gf l i ne q( a, b)
x 2 =
2
1
1
I n the tool box, two functi ons, pr i mes and i s pr i me, are dedi cated to fi ndi ng
pri me numbers and checki ng whether a number i s pr i me. Pl ease see Chapter
5, the MATLAB Function Reference, for exampl es of usi ng these two functi ons.
3-138

4
Exampl es
Bit-Error Rate Computation . . . . . . . . . . . . . 4-3
Background . . . . . . . . . . . . . . . . . . . . . 4-3
Open the COMMGUI Wi ndow . . . . . . . . . . . . . 4-3
Digital Subscriber Telephone Lines (DSL) . . . . . . 4-7
Channel and Noi se Model s . . . . . . . . . . . . . . . 4-8
The Transcei ver Archi tectur e . . . . . . . . . . . . . . 4-9
Performance Si mul ati on . . . . . . . . . . . . . . . . 4-10
References . . . . . . . . . . . . . . . . . . . . . 4-14
Early-Late Gate Synchronization . . . . . . . . . . 4-15
Background . . . . . . . . . . . . . . . . . . . . . 4-15
Communi cati on System Si mul ati on . . . . . . . . . . . 4-18
V.34 Modem Data Transmission . . . . . . . . . . . 4-29
Background . . . . . . . . . . . . . . . . . . . . . 4-29
Si mul ati on Bl ock Di agr am . . . . . . . . . . . . . . . 4-30
Par ameters and Li mi tati ons of the Si mul ati on Desi gn . . . 4-32
Cal l Modem Si mul ati on I mpl ementati on . . . . . . . . . 4-35
Answer Modem Si mul ati on I mpl ementati on . . . . . . . 4-43
4 Exam ples
4-2
Thi s chapter pr ovi des four appl i cati on exampl es. The four exampl es are:
Bi t-err or rate computati on
Thi s exampl e i s a si mpl e tool for computi ng bi t-er ror rate wi th di fferent
modul ati on methods, err or control codi ng methods, and channel noi ses.
Di gi tal subscr i ber tel ephone l i nes
Thi s exampl e si mul ates di gi tal tr ansmi ssi on thr ough a tel ephone l i ne. I t
i ncl udes noi se cancel ati on and equal i zati on model s.
Earl y-l ater gate synchr oni zati on
Synchroni zati on pl ays a vi tal i mpor tant r ol e i n the data tr ansmi ssi on. Thi s
exampl e i mpl ements a compl ete synchr oni zati on system for recei vers.
V.34 modem data transmi ssi on
V.34 modem standard i s the newest standar d for computer data
transmi ssi on through tel ephone l i nes. Thi s exampl e si mul ates the data
transmi ssi on between a cal l modem and an answer modem.
MATLAB and Si mul i nk ar e wi del y used i n i ndustr i al appl i cati ons. The author
of thi s tool box i s pl ani ng to col l ect appl i cati on exampl es i n the communi cati on
ar ea and have them publ i shed i n the for m si mi l ar to the exampl es pr ovi ded i n
thi s chapter . Pl ease send your exampl es to the author at the fol l owi ng addr ess
i f you ar e i nterested i n havi ng them publ i shed:
Wes Wang
The MathWorks, I nc.
24 Pri me Park Way
Nati ck, MA 01760
wang@mat hwor ks . c om
Bit-Error Rate C om putation
4-3
Bit-Error Rate Computation
Background
Thi s secti on pr ovi des an exampl e of how to use the tool box to cal cul ate bi t err or
rates. I t provi des a fl exi bl e tool for the bi t err or rate computati on usi ng
di ffer ent methods and parameter s. You can choose to use techni ques provi ded
i n the tool box or your own method to compute the bi t-err or rate.
Open the COMMGUI Window
Open the gr aphi cal user i nter face (GUI ) wi ndow by typi ng the command
c ommgui
i n the MATLAB workspace. You can al so doubl e-cl i ck on the Bi t-Err or Rate
Computati on bl ock i n the de mo subl i brar y i n the Communi cati ons Tool box
bl ock l i br ary.
4 Exam ples
4-4
Thi s fi gur e shows the GUI wi ndow:
Processi ng method
sel ecti ons
(edi tabl e).
Par ameter entr y
(edi tabl e).
Record of past
computati on
resul ts.
Copy wor kspace
vari abl e to r ecor d
data. Or , copy the
recor d data to
wor kspace.
The or der of
the curve
fi tti ng i n pl ot
(edi tabl e).
Pl ot the compu-
tati on r esul t.
The pl ot i s
enabl ed onl y i f
computati on
data i s avai l -
abl e. The pl ot i s
on a l og-l og
scal e.
Hel p
for how
to use
the
GUI .
Start
computati on.
The pr ocessi ng
stage col or
i ndi cates the
computati on
status.
Computati on
stage.
Cal cul ati on
percentage.
Load or save the
setti ng data.
Hel p for thi s
GUI exampl e.
Record of
cur rent
computati on
resul ts.
Sendi ng recor d
data to tr ash
del etes the
recor d data.
Cl ose
thi s
GUI
fi gur e.
Bit-Error Rate C om putation
4-5
Thi s wi ndow i ncl udes four di fferent functi onal categori es:
Si gnal Source
Err or -Contr ol Codi ng
Modul ati on/Demodul ati on
Channel
You can choose computati on methods i n each of the four categor i es. The
methods can be found i n the pul l -down menus i n each category. Once you have
sel ected a method i n a categor y, you can speci fy the parameter s associ ated wi th
that parti cul ar method i n the data entr y fi el ds l ocated beneath the pul l -down
menus. For exampl e, the fi r st parameter i n the Channel categor y can be a
vector si gnal , whi ch determi nes the computati on l ength.
Buttons to contr ol the executi on are l ocated at the bottom of the wi ndow. After
setti ng the methods and par ameters, cl i ck the Run button to start the
computati on process. The executi on functi on automati cal l y fi l l s the
computati on r esul ts i nto the curr ent data r ecord. The computed data i ncl udes
the si gnal to noi se rati o and the bi t-err or rati o. The computati on stage, whi ch
i s l ocated di rectl y beneath the gr oup of functi onal categor i es, i ndi cates whi ch
stage the cal cul ati ons have r eached i n the processi ng. The cal cul ati on
percentage i ndi cates what percent the total cal cul ati on has occur ed. After the
computati on i s done, cl i cki ng the Plot button opens a fi gur e that pl ots the
bi t-er ror rate.
10
1
10
2
10
4
10
3
10
2
10
1
Signal/Noise Ratio
B
i
t

E
r
r
o
r

R
a
t
e
4 Exam ples
4-6
The pl ot i s on a l og-l og scal e. The fi rst, second, thi r d and cur rent r ecor d data
ar e i ndi cated by the *, x, +, and o symbol s r especti vel y. No cur ve i s dr awn
i f the r ecord i s empty. The cur ves are the r esul t of cur ve fi tti ng wi th the gi ven
data. The curve fi tti ng pol ynomi al or der can be speci fi ed by changi ng the Cur ve
Fi t Or der parameter .
You can r earr ange the data by draggi ng and droppi ng the data r ecord between
r ecords and the workspace area. When you dr op data i nto the trash can, whi ch
i s l ocated i n the l ower ri ght-hand corner of the GUI wi ndow, the data wi l l be
del eted. You can zoom i n and out of the pl ot wi ndow. Ordi nari l y, MATLAB
pl ots the defaul t to zoom off, but i n thi s demo the defaul t i s zoom on. Refer to
the MATLAB Reference Guide or type he l p z oom on the MATLAB command
l i ne for a di scussi on of the z oom functi on.
Pl ease note that the chosen par ameters must fi t the r equi r ements of the
computati on. I f you dont know a good val ue for a par ameter, l eave i t empty.
The functi on wi l l choose the defaul t computati on par ameter for you.
You can save the wi ndow par ameter setti ng i nto a data fi l e by choosi ng the File
pul l -down menu at the top l eft cor ner of the wi ndow. You may l oad saved data
after you have saved a wi ndow setti ng. The Help pul l -down menu provi des
onl i ne hel p for how to use the functi on.
D igital Subscriber Telephone Lines (D SL)
4-7
Digital Subscriber Telephone Lines (DSL)
Thi s exampl e i s pr ovi ded by Wal ter Y. Chen of Texas I nstr uments, I nc. (13510
North Central Expressway, Mai l Stop 446, Dal l as, TX 75265). The author of
thi s tool box has revi sed the desi gn of the exampl e.
Di gi tal Subscri ber Li nes (DSLs)[1][2][3] ar e used to connect tel ephone
subscri ber s to l ocal centr al offi ces (COs) over the tradi ti onal twi sted pai r
tel ephone subscri ber l i nes. These di gi tal connecti ons can provi de symmetri cal
or asymmetr i cal tr ansmi ssi on wi th a throughput between a few 100 kbps to a
few Mbps.
The I ntegr ated Ser vi ces Di gi tal Network (I SDN) basi c r ate access channel
avai l abl e now through tel ephone compani es i s based on the Di gi tal Subscri ber
Li ne (DSL) technol ogy. That DSL has a net (echo cancel l ati on based) dupl ex
tr ansmi ssi on throughput of 160 kbps. The transmi ssi on i s car ri ed out wi th a
2B1Q l i ne code wi th a baud r ate of 80 kHz. The base tr ansmi ssi on spectrum i s
from DC to 40 kHz.
The repeaterl ess T1 servi ce i s based on the Hi gh bi t-r ate Di gi tal Subscri ber
Li nes (HDSL) technol ogy. HDSL empl oys the same 2B1Q l i ne code as does the
DSL but wi th a hi gher baud r ate of 400 kHz. Thi s resul ts i n a base
tr ansmi ssi on bandwi dth of about 200 kHz. The hi gher transmi ssi on
throughput i s achi eved by usi ng hi gher speed si gnal processi ng har dwar e i n
conjuncti on wi th a smal l er servi ng di stance.
The maxi mum tr ansmi ssi on thr oughput of a DSL system i s l i mi ted by the
subscri ber l oop channel l oss and the cor respondi ng noi se envi ronment. For
DSL and HDSL the noi se envi r onment i s domi nated by sel f Near End
Crosstal k (NEXT). The sel f NEXT i s defi ned by the i nter fer ence from adjacent
tr ansmi tters wi th si mi l ar DSL systems at the same centr al offi ce or r esi dence.
4 Exam ples
4-8
Channel and Noise Models
A typi cal tel ephone subscr i ber l i ne has a l ength of ni ne kft (26 AWG). The
squar ed channel transfer functi on can be appr oxi mated as
for 9 x 10
-7
, and d=9000 ft.
Besi des the channel l oss, the tr ansmi ssi on per for mance i s al so l i mi ted by
channel noi se. I t consi sts of Near End Crosstal k (NEXT), Far End Crosstal k
(FEXT), and whi te backgr ound noi ses. The NEXT and FEXT noi se power i s
dependent on the coupl i ng functi on and the di sturbi ng sour ce power densi ty.
The squared NEXT coupl i ng transfer functi on i s
H
e
f ( )
2
e
2 d f

H
NEXT
f ( )
2
f
3 2
=
D igital Subscriber Telephone Lines (D SL)
4-9
where 8.8 x 10
-14
for 49 di stur ber 1% wor st case. The val ue of shoul d be
modi fi ed accordi ng to
for di ffer ent number, n, of di stur bers.
The squared FEXT coupl i ng tr ansfer functi on i s
where 8 x 10
-20
for 49 di sturber 1% wor st case and the same scal i ng method
al so appl i es to .
The power spectr um densi ty of the I SDN basi c access rate ser vi ce can be
expressed as
for f
0
= 80 kHz.
The Transceiver Architecture
The echo cancel l ati on based DSL transcei ver can be real i zed wi th the
mul ti -l evel pul se ampl i tude modul ati on techni que. The tr anscei ver structures
at each end of a DSL system are i denti cal . The transmi tter part of a DSL
consi sts of a di gi tal shapi ng fi l ter , a D to A converter , and an anti -al i asi ng
fi l ter. The r ecei ver par t consi sts of an anal og l owpass fi l ter, an A to D
converter , and a baud r ate channel equal i zer s. An echo cancel l er i s used to
separ ate the r ecei ved si gnal from the transmi t si gnal .

49
n
6
10
------
10
--------- =
H
FEXT
f ( )
2
f
2
d H
e
f ( )
2
=
PSD
I SDN
3.017
f
s
f
0
----
si n
2f
f
0
-----
f
f
0
-----
,
_
2
----------------- =
4 Exam ples
4-10
Performance Simulation
The DSL si mul ati on can be carr i ed out wi th tr ansmi tter , channel , noi se, echo
path, and r ecei ver model s.
The transmi tter i s si mpl y a combi nati on of a r ai sed-cosi ne fi l ter and a PAM
si gnal source. The channel consi sts of a l oop model and a noi se model , both of
whi ch ar e presented as FI R fi l ters, i n conjuncti on wi th a noi se generator. The
channel model i s gener ated by fi rst cal cul ati ng the channel transfer functi on
and then the channel i mpul se response for the FI R fi l ter vi a Di screte Fouri er
tr ansfor m. The noi se model i s cal cul ated by desi gni ng an FI R fi l ter to fi t the
spectrum of the noi se envi r onment whi ch i s the cascadi ng of the HDSL
Shapi ng
Fi l ter
D/A
Convert
Anti -al i as
Fi l ter
Echo
Cancel
Hybr i d
Lowpass
Fi l ter
A/D
Convert
Channel
Equal i zer
Deci si on
Devi ce
+
Twi sted
Loop
Tr ansmi tted Si gnal
Recei ved
Si gnal
k
z
k
z
PAM Signal
Channel
Receiver
Mux
+
+
[.1 1.1]
Constant
Received
signal
Transmitter
D igital Subscriber Telephone Lines (D SL)
4-11
tr ansmi t power spectr um and the squared NEXT coupl i ng transfer functi on.
The effect of noi se i s then si mul ated by dri vi ng thi s FI R fi l ter wi th a whi te
Gaussi an noi se whose power i s adjusted to 0 dBm/Hz. A si mpl i fi ed echo path
model consi sts of an over damped second order system. The echo model i s al so
repr esented by an FI R fi l ter . The transfer functi on of the echo path i s
where , , , , ,
, .
The recei ver i s a combi nati on of a Bessel l owpass fi l ter and an adapti ve
channel equal i zer . The r ecei ver al so has an echo cancel l er that cancel s echos
gener ated by the combi nati on of the echo path model and another PAM si gnal
sour ce. The tr ansmi tted si gnal i s r el ayed to the recei ver for the i ni ti al equal i zer
tr ai ni ng. Wi th the absence of the far end si gnal , the echo cancel l er i s fi rst
tr ai ned to reduce the echo l evel by about 60 dB. After the i ni ti al convergence of
the echo cancel l er, the adaptati on step si ze of the echo cancel l er i s r educed to
a much smal l er val ue to keep tracki ng the possi bl e vari ati ons of the echo path
tr ansfer functi on wi th the pr esence of the r ecei ved si gnal .
Si mul ati on r esul ts can be exami ned by di spl ayi ng tr ansmi tted and recei ved
si gnal , equal i zer output err or , equal i zer coeffi ci ents, and echo cancel l er
coeffi ci ents. A snap shot of the tr ansmi tted and recover ed si gnal i s shown i n
the next fi gur e. An arti fi ci al shi ft has been added to di sti ngui sh the two
di ffer ent si gnal s.
H s ( )
1
2
---
R
12
Z
0
R
12
+
-----------------------
s s
1
C
1
R
2
-------------- +
,
_
s
2 1
C
1
R
Z1
R
2
+ ( )
-------------------------------------
R
Z12
L
p
------------- +
,
_
s
R
Z1
C
1
R
Z1
R
2
+ ( )L
p
-------------------------------------------- + +
-------------------------------------------------------------------------------------------------------------------------------- =
Z
0
135 = R
12
99 = R
2
124 = R
Z1
106 = R
Z12
57 =
C
1
0.033F = L
p
1.5mH =
4 Exam ples
4-12
The Receiver
The bl ock di agr am of the recei ver i s shown bel ow. The recei ver contai ns echo
cancel l ati on, an equal i zer, and a l ow pass fi l ter .
You can open the equal i zer bl ock to l ook i nto the bl ock di agram structur e of the
equal i zer. The equal i zer i s mai nl y constructed by usi ng a feedforward fi l ter
and a feedback fi l ter. The str uctur e of the equal i zer i s shown i n the fol l owi ng
fi gure.
Switch 2
2
in_2
Switch 1
PAM
Signal
Step Input
1
in_1
Switch 3
Echo
Canceler
DTDMA
mux
Equalizer
+
+
Butterworth
LP Filter

+
echop(z)
1
Filter1
MASK
demap
MASK demap
1/z
Echo Canceler
Coef. view
1
out_1
D igital Subscriber Telephone Lines (D SL)
4-13
The Step I nput bl ock i n the Recei ver subsystem provi des a swi tch si gnal .
Befor e the step si gnal becomes one, the system i s i n a tr ai ni ng peri od. The
equal i zer and echo cancel l ati on parameter s are tr ai ned i n the trai ni ng per i od.
Thi s exampl e has pl aced the trai ned par ameters as i ni ti al condi ti ons at the
begi nni ng of the si mul ati on, whi ch enabl e you to see the si mul ati on r esul t
wi thout wai ti ng to the end of the tr ai ni ng peri od. I f you prefer to see the
tr ai ni ng peri od, you can set the parameter s X1_i ni , X2_i ni , and X3_i ni to be
zero vector s i n the MATLAB workspace. You shoul d set the Step Ti me i n the
Step I nput bl ock to be 50 seconds i nstead of 0 seconds. Before the 50 seconds,
i t i s the trai ni ng per i od. You can open the Echo Cancel er Coef. Vi ew scope (i n
the Recei ver subsystem), the Equal i zer FFF Vi ew scope (i n the Equal i zer
subsystem), and the Equal i zer FBF Vi ew scope (i n the Equal i zer subsystem) to
vi ew the par ameter trai ni ng pr ocess. A snap shot of the parameter s dur i ng the
2
in_2 1
in_1
Equalizer
FBF view
DTDMA
mux
Feedback
Filter
1/z
1
Equalizer
FFF view
DTDMA
mux
Error
1/z

+
0.01
Feedforward
Filter
+

1
out_1
4 Exam ples
4-14
tr ai ni ng i s shown i n the fi gure bel ow. Note that the fi gure di spl ays the val ues
of each el ement i n the vector:
References
[1] I EEE J ournal on Selected Areas in Communications, Speci al I ssue on Hi gh
Speed Di gi tal Subscr i ber Li nes (HDSL), Vol . 9, No. 6, August 1991.
[2] I EEE J ournal on Selected Areas in Communications, Speci al I ssue on
Copper Wi r e Access Technol ogi es for Hi gh Per for mance Networ ks, Vol . 13, No.
9, December 1995.
[3] Chen, W.Y, Archi tectur e and per for mance si mul ati on of a si ngl e pai r
HDSL, I EEE I CC 96 Proc.
Echo Cancel l er Coef. vi ew Equal i zer FFF vi ew Equal i zer FBF vi ew
Early-Late G ate Synchronization
4-15
Early-Late Gate Synchronization
Thi s exampl e i s pr ovi ded by Darr el Judd of Harman Moti ve (1201 South Ohi o
Str eet, Mar ti nsvi l l e, I N 46151).
When a communi cati ons si gnal i s r ecei ved, i t must be synchr oni zed to the
system that recei ves i t. Dependi ng on the type of demodul ati on scheme used,
i t may be i mpor tant to know the cor rect carr i er frequency and phase. Thi s i s
cal l ed car ri er synchr oni zati on. I f the si gnal i s a data si gnal , i t i s al so i mportant
to synchroni ze to the symbol peri ods of the data. Thi s i s cal l ed data
synchroni zati on. There are many ways that the synchroni zati on probl em has
been sol ved: pi l ot tones, preambl es, phase l ocked l oops, etc. Thi s exampl e
assumes that the si gnal of i nterest i s a two tone FSK si gnal . I t i s al so assumed
that the baud rate i s known, but the starti ng poi nt of each bi t i s not known.
Thi s tutori al uses an ear l y-l ate gate techni que to baud synchr oni zati on to the
i nstantaneous fr equency output of an FM detecti on process. The Si mul i nk
functi on i s cal l ed e l g. m.
Background
The earl y-l ate gate synchroni zer i s a ver y popul ar techni que. A bl ock di agr am
of the al gori thm i s shown bel ow. Thi s ver si on wor ks for r ectangul ar pul ses.
The basi c pr i nci pl e for thi s data synchi ng techni que i s to compare the energy
i n the fi r st hal f of a symbol peri od to the ener gy i n the l ast hal f of a symbol
1
T
---- . ( ) t d
t
0
t
0
T
2
--- - +

1
T
---- . ( ) t d
t
0
t
0
T
2
--- - +

Sampl e
and Hol d
Sampl e
and Hol d
.
.
+
VCO
fi l ter
Loop
Ti mi ng
Output
cl ock
t
0
t t
0
T
2
---- + <

' ;

t
0
T
2
---- +

' ;

I nput
si gnal
4 Exam ples
4-16
peri od. (Earl y and Late gate, r especti vel y). There ar e four condi ti ons that
can occur :
Condi ti on 1. The l oop has l ocked to the symbol per i od. The ener gy l evel s ar e
equal . Thi s means that a symbol transi ti on was not found i n thi s symbol
per i od. No ti mi ng cor recti on i s made for thi s condi ti on.
Condi ti on 2. Two i denti cal symbol s have been tr ansmi tted. The energy l evel s
are equal . Thi s means that a symbol transi ti on was not found i n thi s symbol
per i od. No ti mi ng cor recti on i s made for thi s condi ti on.
Condi ti on 3. The ener gy i n the ear l y gate i s gr eater than the energy i n the
l ate gate. Thi s means that ther e was a symbol transi ti on i n the l ast hal f of a
symbol peri od. A ti mi ng corr ecti on can now be made to synchr oni ze up to the
symbol boundary.
Condi ti on 4. The ener gy i n the l ate gate i s greater than the ener gy i n the
earl y gate. Thi s means that ther e was a symbol tr ansi ti on i n the ear l y gate.
A ti mi ng corr ecti on can now be made to synchroni ze up to the symbol
boundary.
Early-Late G ate Synchronization
4-17
These four cases are shown graphi cal l y i n the fol l owi ng fi gur e.
The basi c steps of the al gor i thm ar e l i sted bel ow:
1 Gi ven a data si gnal s(t), choose an arbi trar y poi nt i n ti me, t
0
. Thi s poi nt l i es
somewhere wi thi n a symbol boundary. Let thi s poi nt be s(t
0
).
2 Let the symbol peri od be T, where 1/T i s the symbol r ate.
3 Now defi ne a wi ndow i n ti me as . Thi s wi ndow i s cal l ed the
ear l y gate.
4 Now defi ne a wi ndow i n ti me as . Thi s wi ndow i s cal l ed the
l ate gate.
Condi ti on 3
Condi ti on 4
Condi ti on 1 Condi ti on 2
t
0
t t
0
T
2
---- +
t
0
T
2
--- - + t t
0
T +
4 Exam ples
4-18
We now have two adjacent wi ndows that cover one symbol peri od, but the
starti ng poi nt of the symbol i s not known. I f we l ook at the amount of ener gy i n
each gate, we can deduce i f i t i s at a symbol boundary. I f the ener gy i n the ear l y
gate i s greater than the ener gy i n the l ate gate thi s means that the si gnal
tr ansi ti oned dur i ng the l ate gate. Our poi nt of reference, coul d now be
decr eased and we woul d be one step cl oser to knowi ng the symbol boundary.
Communication System Simulation
To r un thi s si mul ati on as i t i s descri bed, open the Demo wi ndow i n the
Communi cati ons Tool box Mai n Wi ndow. When the Demo wi ndow i s opened
you shoul d see a wi ndow l abel ed Early Late Demo. Thi s fi gur e shows the
wi ndows contents:
MFSK Rd wksp
f1num(s)
f1den(s)
AntiAliasing
Filter
?
K
ELG
Discrete
EarlyLate
Gate
Mux
Rd wksp
AWGN
SNR
.
FM
Detect
Fmdetect
Integrate, Sample,
and Threshold
DDC
Digital Down
Convert
Error Rate
Meter
Early-Late G ate Synchronization
4-19
The si mul ated system can be br oken down i nto four basi c ar eas:
The generati on and modul ati on of a di gi tal si gnal . Thi s i s shown i n the fi r st
thr ee bl ocks.
The tr ansmi ssi on of the si gnal thr ough a communi cati ons channel .
The demodul ati on of the recei ved si gnal . Thi s process i s represented by the
bl ocks i n the l ower hal f of the fi gur e.
The moni tori ng of the resul ts. Resul ts ar e di spl ayed i n a gr aph wi ndow and
wi th an Er ror Rate Meter wi ndow.
The basi c par ameters of the si mul ati on; sampl e peri od (t s s ), symbol peri od
(t dd), car ri er frequency (Fc), tone spaci ng (Fs hi f t ), and number of tones (MM),
can be modi fi ed fr om the MATLAB workspace after the el g wi ndow has been
opened.
The fi rst step i n the si mul ati on i s to gener ate a di gi tal communi cati ons si gnal .
A two-tone FSK si gnal i s gener ated. Next, noi se i s added to the si gnal wi th the
bl ock, AWGN SNR. On the r ecei vi ng si de, the si gnal i s fi r st down converted to
remove a carr i er and separated i nto quadrature components. Thi s i s done wi th
the bl ock DDC. The i nstantaneous frequency of the baseband si gnal i s then
cal cul ated usi ng the FM Detect bl ock. Now the processed si gnal i s r eady to be
i nput i nto the Di screte Earl y-Late Gate bl ock. The outputs of thi s bl ock are two
ti mi ng si gnal s. These si gnal s ar e synchr oni zed to the symbol boundari es of the
detected FSK si gnal . These ti mi ng si gnal s ar e then used to extr act the ori gi nal
tr ansmi tted symbol s from the i nstantaneous fr equency. The resul ts ar e then
compar ed to a del ayed ver si on of the or i gi nal di gi tal message wi th the Er ror
Rate Meter bl ock. The rest of the bl ocks are used to di spl ay the resul ts of the
si mul ati on. The Tr anspor t Del ay bl ock i s needed because ther e i s an i nherent
phase del ay caused by the Phase Locked Loop used i n the Di scr ete Ear l y-Late
Gate bl ock.
Signal Simulation
The two-tone FSK si gnal i s generated by the top l eft three bl ocks i n the system
bl ock di agram. The Rdwksp bl ock i s set up to gi ve conti nuous random number s
rangi ng between 0 and 1. The output of thi s bl ock i s sent to the MFSK Mod
bl ock. The bi nary data i s al so sent to the Er ror Rate Meter bl ock so that the
ori gi nal data can be compared wi th the demodul ated data l ater i n the
si mul ati on.
4 Exam ples
4-20
The MFSK Mod bl ock modul ates the di gi tal data stream accordi ng to the
par ameters l i sted ear l i er.
Because rectangul ar pul se shapi ng i s used for thi s si mul ati on, and because a
r ectangul ar pul se i s ti me l i mi ted, the r esul ti ng si gnal wi l l have i nfi ni te
bandwi dth i n the fr equency domai n. I n order to sol ve thi s probl em, an
anti -al i asi ng fi l ter i s added to l i mi t the bandwi dth of the si gnal . The bandwi dth
i s chosen to be 4000 Hz. I t shoul d be noted that i f t s s i s changed for thi s
si mul ati on that the Anti -Al i asi ng fi l ter r ol l -off frequency wi l l need to be
changed i n the Mask for the FSK2 bl ock. The output si gnal of thi s bl ock, and
i ts power spectr al densi ty ar e shown bel ow.
Communications Channel
The bl ock di agr am of the AWGN SNR bl ock i s shown i n the next fi gure. Thi s
bl ock adds addi ti ve whi te Gaussi an noi se (AWGN) to the si gnal at i nput por t
1. The si gnal to noi se rati o (SNR), i n dB, i s deter mi ned by the val ue pr esent at
Early-Late G ate Synchronization
4-21
the second i nput port. Dur i ng the system si mul ati on, the SNR ranges from -5
dB to 10 dB. The SNR l evel i s i ncremented by one dB ever y 20 symbol per i ods.
By changi ng the SNR r ange, an err or fr ee operati ng range for the system can
be deter mi ned:
Signal Demodulation
The si gnal demodul ati on process i s repr esented by the bl ocks i n the l ower hal f
of the e l g bl ock di agram.The demodul ati on i s accompl i shed by Di gi tal Down
Conver t, FM Detect, Di scr ete Ear l y-Late Gate, and I nter grate Sampl e and
Thr eshol d bl ocks.
Digital Down Converter. Once the si gnal has passed through the
communi cati ons channel , i t must be sampl ed and down conver ted to baseband.
Thi s i s done wi th the DDC bl ock. The anal og i nput i s fi r st fi l tered to ensur e
that i t i s band l i mi ted. Then i t i s sampl ed wi th a Zer o-Or der Hol d bl ock.
At thi s poi nt, the si gnal processi ng i s best descr i bed by the fol l owi ng equati ons:
2
in_2
Pulse
Pulses divide
same sample time1
*
Product
K
Gain
.
Inner
Product
Reg. shift
Registershift
sqrt(u[1])
1
out_1
AWGN
AWGN
w vary para
1/10^(u[1]/10) 1
in_1
0
zero mean
s t ( ) s nT ( ) =
I nT ( )
A
2
----
c
t nT ( ) cos
A
2
----
c

s
t ( )nT ( ) cos + =
Q nT ( )
A
2
----
c
t nT ( ) si n
A
2
----
c

s
t ( )nT ( ) si n + =
s nT ( ) A
c

s
t ( )nT ( ) cos =
I nT ( ) s nT ( )
c
nT ( ) cos =
Q nT ( ) s nT ( )
c
nT ( ) cos =
4 Exam ples
4-22
The overal l pr ocess for the DDC i s shown i n the fol l owi ng fi gure.
A ti me pl ot and power spectral densi ty pl ot of I (nT) are shown i n the fi gur e
bel ow, note the twi ce carr i er peaks, , i n the power spectral densi ty.
1
analog
in
2
quadrature
1
inphase
*
*
f2num(z)
f2den(z)
Discrete
Transfer Fcn
f2num(z)
f2den(z)
Discrete
Transfer Fcn1
f1num(s)
f1den(s)
Antialiasing
Filter
12:34
Digital Clock
cos(2*pi*(Fc+Fshift/2)*u[1])
sin(2*pi*(Fc+Fshift/2)*u[1])
2
c

s
t
Early-Late G ate Synchronization
4-23
The terms are fi l ter ed out of I and Q wi th i denti cal l ow pass fi l ters. The
cut off frequency for these fi l ter s i s deter mi ned by the symbol r ate used. An
exampl e of how thi s i s done i s shown i n the next fi gure.
The cutoff frequency i s chosen such that the mai n l obes of the spectr um and
tone spaces are i ncl uded i n the pass band. I f the f s hi f t fr equency between the
two tones i s l ar ge enough, a band pass fi l ter can be pl aced around each mai n
l obe. Thi s hel ps to el i mi nate i nter symbol i nterference. Another sol uti on to the
symbol i nterfer ence probl em i s to use a pul se shapi ng fi l ter. The r esul ts of the
fi l teri ng process are shown i n the bel ow fi gure. Note that the terms have
2
c
+
2
c
4 Exam ples
4-24
been fi l ter ed out. The qual i ty of thi s fi l ter i ng determi nes the spur -fr ee dynami c
r ange of the DDC:.
The FM Detect Block. The i nstantaneous fr equency i s cal cul ated fr om the
compl ex si gnal accor di ng to the fol l owi ng equati on:
Thi s method wor ks wel l for hi gh si gnal -to-noi se r ati o condi ti ons.
The FM Detect bl ock i s shown i n the fol l owi ng fi gur e. The der i vati ve i s
si mul ated wi th a fi r st order di ffer ence consi sti ng of a uni t del ay and subtr act.
freq nT ( )
d a
Q nT ( )
I nT ( )
------------------
,
_
tan
,
_
dt
---------------------------------------------- =
Early-Late G ate Synchronization
4-25
A pr obl em wi th thi s techni que i s that when the phase of the compl ex si gnal
moves from quadrant 3 to quadr ant 2 or 4, l arge noi se spi kes are gener ated i n
freq(nT). Thi s i s shown i n the fi gur e bel ow:
Reg. shift
1
in_1
2
in_2
f(u)
1/z
+

Mux
MATLAB
Function
1
out_1
Pulse
0.025 0.026 0.027 0.028 0.029 0.03 0.031 0.032 0.033
1
0.8
0.6
0.4
0.2
0
0.2
0.4
0.6
0.8
1
Time (second)
4 Exam ples
4-26
These spi kes ar e easi l y removed wi th a fi ve tap medi an fi l ter . The medi an fi l ter
i s i mpl emented wi th the Regi ster Shi ft bl ock and the MATLAB Functi on bl ock.
The fi gure shows the r esul ts of the fi l teri ng:
The Discrete Early-Late Gate Block. The di agram for the Earl y-Late Gate
bl ock i s shown i n the next fi gur e. There are two outputs for the bl ock:
A squar e wave representi ng the ear l y gate
A squar e wave for the l ate gate
0.025 0.026 0.027 0.028 0.029 0.03 0.031 0.032 0.033
1
0.8
0.6
0.4
0.2
0
0.2
0.4
0.6
0.8
1
Time (second)
Early-Late G ate Synchronization
4-27
The symbol boundary i s at the fal l i ng edge of the earl y gate and at the r i si ng of
the l ate gate:
The output of the Di screte Earl y Late Gate bl ock, and the i nstantaneous
frequency output from the FM Detect bl ock are shown i n the next fi gur e. The
earl y and l ate gate wave for ms ar e al i gned wi th the symbol boundar i es. The
other sol i d l i ne i s the SNR l evel . For thi s pl ot the SNR was 6 dB.
The Ear l y Late Gate techni que of synchr oni zati on can be used for other ki nds
of demodul ati on techni ques. The FM Detecti on process coul d be r epl aced wi th
1
in_1
Sign
Discrete
VCO
+

1
Constant
*
+
+
Discrete
Resettable
integrator
Abs
Discrete
Sample
and Hold
K
2
Abs
Discrete
Sample
and Hold
K
Discrete
Resettable
integrator
1
4 Exam ples
4-28
a matched fi l ter. The energy output fr om each fi l ter coul d then be used to
generate the err or functi on.
The symbol boundar i es ar e deter mi ned by the Earl y Late Gate bl ock. The
outputs fr om the Earl y Late Gate bl ock can now be used to tri gger an i ntegr ate
and dump over each symbol peri od. The output of the i ntegrator can then be
compared to a thr eshol d to deter mi ne each symbol .
Each demodul ated symbol i s now compared to the tr ansmi tted symbol . An
err or count and rate i s tabul ated wi th the Err or Rate Meter bl ock.
Note: Pl ease r efer to F.M. Gar dners Phase-Locked Loops for a mor e detai l ed
di scussi on on earl y-l ate synchr oni zati on.
0.367 0.368 0.369 0.37 0.371 0.372 0.373 0.374 0.375
10
8
6
4
2
0
2
4
6
8
10
Time (second)
V.34 M odem D ata Transm ission
4-29
V.34 Modem Data Transmission
Background
Modems are desi gned to transfer data between computers through tel ephone
l i nes. To ensure the cor rect transmi ssi on of data between two di fferent
modems, the I nter nati onal Tel egr aph and Tel ephone Consul tati ve Commi ttee
(CCI TT) has i ssued a number of standards for data communi cati on over
tel ephone networks. The standards for modems are speci fi ed wi th the i ni ti al
character V, known as the V seri es. V ser i es are useful for data protocol , data
tr ansl ati on, data compressi on, etc. The standards are as fol l ows:
The V.34 modem i s a standar d from CCI TT (now, referr ed to as the
I nter nati onal Tel ecommuni cati on Uni on-Tel ecommuni cati on (I TU-T)
Standardi zati on Sector ) for tel ephone l i ne data tr ansmi ssi on publ i shed on
September, 1994. I t i s the l atest modem standard avai l abl e. The maxi mum bi t
tr ansmi ssi on r ate i s 28,800 bi ts per second. The fol l owi ng exampl e shows an
i mpl ementati on of the V.34 modem. The exampl e i s desi gned to cl ear l y fol l ow
the structure descri bed i n the standar d. Ti me effi ci ency and speed are not the
key consi der ati ons i n the i mpl ementati on. You can use thi s exampl e to
under stand the detai l ed structures and data fl ow of a V.34 modem. You can
al so modi fy thi s exampl e to construct your own i mpl ementati on.
Refer to U. Bl acks The V Series Recommendations for a detai l ed di scussi on of
the CCI TT standar d before V.34.
V. Series Functionality
V.1-V.8 Gener al descr i pti on of codi ng, symbol rate, and
power l evel s for modem.
V.10-V.34 The si gnal conventi ons standard for modems
usi ng voi ce fr equency tel ephone l i nes.
V.36-V.38 The si gnal conventi ons standard for wi de band
modems.
V.41-V.42 Err or-control conventi on.
V.50-V.57 Testi ng method, noi se measur ement
speci fi cati on.
V.100, V.110, V.120,
and V.230
I nter networki ng speci fi cati ons wi th packet and
I SDN networks.
4 Exam ples
4-30
Simulation Block Diagram
Thi s exampl e si mul ates the data transl ati on process onl y. The modem star t-up
tr ai ni ng befor e the data tr ansl ati on i s not i ncl uded. The exampl e assumes that
the par ameters between the Cal l Modem and the Answer Modem are the same.
I n thi s exampl e, the Cal l Modem transmi ts data to the Answer Modem. The
data to be tr ansmi tted are random bi nar y number s gener ated i nsi de the Cal l
Modem. The fi rst output port of the Cal l Modem outputs the baseband QAM
modul ated si gnal . The transmi ssi on channel i s assumed to be a Rayl ei gh noi se
channel . The Answer Modem uses the recei ved si gnal to recover the si gnal
tr ansmi tted over the tel ephone l i ne. I t i s assumed that the Answer Modem
shar es the same par ameters as those used i n the Cal l Modem. The enabl e
si gnal s are pl aced to i ndi cate the data tr ansl ati on peri od.
The second output por t of the Cal l Modem contai ns i nteger s that ar e sent to the
Answer Modem. The sampl e rate of the data i s:
. 28/v 34_r at e _p/v 34_r at e _j /4
The i nteger contai ns v 34_r at e_b/4 bi ts of the message. (The next secti on
detai l s the defi ni ti ons of the par ameters v 34_r at e _p, v34_r at e_j and
v 34_r at e_b.) The output of the Answer Modem has the same format as the
second output of the Cal l Modem.
The si mul ated data are compared i n the Err or Rate Meter bl ock. Note that
there i s a ti me del ay between the Cal l Modem data and the Answer Modem
r ecovered data. You may need to tune the par ameter Del ay between the i nput
and output i n the Er ror Rate Meter bl ock.
Answer
modem
Call
modem
Error
meter
1
Enable signal1
1
Enable signal2
Update
data
Rayl N
V.34 M odem D ata Transm ission
4-31
The Cal l Modem and the Answer Modem ar e desi gned as ready-to-use bl ocks.
You can i nput par ameters to the di al og box for di ffer ent si mul ati on
parameter s. The di al og box i s as fol l ows:
The di al og box for the answer modem i s:
Date transfer symbol rate. The valid entry
numbers are 2400, 2800, 3000, and 3200 in
this simulation.
Date transfer bit rate. The valid entry numbers
are 2400, 4800, 7200, 9600, 12000, 14400,
16800, 19200, 21600, 24000, 26400, and
288000 in this simulation. Read the Parame-
ters and Limitations of the Simulation De-
sign subsection for the limitations of the rate
assignment.
Use of different convolution encoders. The
valid numbers are 1, 2, and 3, which indicate
the 16, 32, and 63 state convolution encoder is
used.
A complex vector, which contains the
coefficients of the precoder filter.
1 3
4 Exam ples
4-32
You can use the bl ock di r ectl y for the si mul ati on.
Li ke most other bl ocks i n the tool box, the modem si mul ati on bl ocks are
constr ucted by usi ng the combi nati on of Si mul i nk bui l t-i n bl ocks and
S-functi ons. The constr ucti on of the bl ocks takes advantage of the r eady-to-use
bl ocks i n the Communi cati ons Tool box. To see the detai l ed desi gn of the bl ocks,
unmask the bl ocks and doubl e-cl i ck the bl ock.
Parameters and Limitations of the Simulation
Design
You shoul d read the I TU-T recommendati ons to under stand ful l y the system
desi gn, par ameter setti ngs, and the techni ques shown i n the modem
si mul ati on. You can order the standard fr om I TU-Sal es Depar tment, Pl ace des
Nati ons, CH-1211 Geneve 20 Sui sse, Geneva, Swi tzerl and (4122) 730-5285.
I n the fol l owi ng di scussi on, tabl es and fi gur es usi ng the reference V.34 mean
that the tabl e or fi gur e can be found i n the V.34 standard.
These parameters should match their counter-
parts in the Call Modem dialog box.
The delay steps in the convolution decoding.
Refer to the Convol Decoder block or dec ode
function for details.
V.34 M odem D ata Transm ission
4-33
The tabl e bel ow l i sts the defaul t val ues used i n the si mul ati on You can change
a vari abl e by assi gni ng a new vari abl e name i n the MATLAB workspace, or by
di rectl y changi ng the vari abl es i n parameter fi el ds i n the di al og box. The
var i abl es wi th empty var i abl e names i n the tabl e i ndi cate that a scal ar or
vector i s di rectl y assi gned i n the di al og box i n the Si mul i nk bl ock i n thi s
exampl e.
The l ast thr ee vari abl es are cal cul ated by usi ng functi on v34pr e p. I n thi s
exampl e, you can cal cul ate the other par ameters by assi gni ng the three
var i abl es i n the tabl e and doubl e-cl i cki ng the Update Data bl ock. The Update
Data bl ock executes the v 34pr e p functi on and gener ates a MATLAB fi gure. On
the top of the MATLAB fi gur e i s a l i st of cal cul ated par ameters. At the bottom
of the fi gur e i s a pl ot of the modul ati on constel l ati on used i n matchi ng the data
l i sted i n the fi r st part of the fi gur e. The pl ot i ncl udes onl y one quarter of the
constel l ati on poi nts. The compl ete constel l ati on i s the combi nati on of the l i sted
constel l ati on and the 90, 180, and 270 degree rotati ons of the constel l ati on.
Description Variable
Name
Value
Symbol r ate, S SRATE 3200
Bi t r ate, R BRATE 28800
Convol uti on encoder CON_CODE 1
Precode fi l ter coeffi ci ents
Convol uti on decoder del ay steps 10
Number of bi ts per map frame, b v34_r at e_b 72
Number of data frames per
superframe, J
v34_r at e_j 7
Number of map fr ame per
datafr ame, P
v34_r at e_p 16
[1 .8 .4] 1 [1 .5 .2] +
4 Exam ples
4-34
Symbol Rate S: 3200
Bit Rate R: 28800
# of Dataframe per Superframe J: 7
# of Mapframe per Dateframe P: 16
# of bit per Dataframe N: 1152
# of bit per Mapframe b: 72
# of dividing bit in parser q: 4
# of shell mapping bit K: 28
# of rings in shell mapping M: 12
Extended M: 14
# of points in 2D constellation L: 768
Extended L: 896
One quarter of the points in the constellation:
30 20 10 0 10 20 30
30
20
10
0
10
20
30
0 1
2 3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
Inphase
Q
u
a
d
r
a
t
u
r
e
V.34 M odem D ata Transm ission
4-35
You can use the functi on v 34c ons t to cal cul ate or pl ot the constel l ati on poi nts
wi th the gi ven r equi r ements.
The si mul ati on i s desi gned for the cases when al l bi ts i n SWP, the frame
swi tchi ng patter n, are al l ones. Pl ease check Tabl e 8/V.34 for l i mi tati ons. I n the
desi gn, you can cal cul ate the r ati o of
Symbol _r at e _S/Bi t _r at e _R
The bl ocks i n thi s exampl e wor k when the r ati o between these two rates i s an
i nteger.
The si mul ati on desi gn i s sui tabl e when the number of map frame bi ts b i s
l ar ger than 12.
When thi s exampl e cannot si mul ate the data speci fi ed i n SRATE and BRATE,
the executi on of a doubl e Update Bl ock wi l l show a war ni ng l i ne i n the fi gure.
The er ror means the desi gned Cal l Modem and Answer Modem cannot
si mul ate your gi ven r ate.
Call Modem Simulation Implementation
You can unmask the Cal l Modem bl ock to see the detai l s of the i mpl ementati on
of the Cal l Modem. The top l evel of the Cal l Modem i s:
When the Cal l Modem i s enabl ed to tr ansl ate data, the enabl e si gnal enabl es
the synchroni zati on pul ses subsystem to gener ate pul ses to star t the data
Vec to sca
converter
Vct rearr 2
input binary
Uo(m)
QAM Demux
x(n)
Nonlinear
encoder y(m)
1
Modulated
input
Trellis code
x(n)
Rotation Precoder
c(m)
NOT
QASK
Amap
Z(m)
I1ij(m)
Differential
encoder
Q(n)
Demux
Iij
Scramble
Parser and
shell mapping
1
Inport
Synchronization
pulses
Rd wksp
v(n)
4 Exam ples
4-36
tr ansl ati on pr ocess. The data to be tr ansfer red i n thi s exampl e i s a random
bi nary i nteger , gener ated fr om the Read from Wor kspace bl ock. The l ength
v 34_r at e_b bi nar y vector i s di vi ded i nto four secti ons. Each secti on takes a
4-D symbol i nter val to conver t the v 34_r at e _b/4 bi t bi nar y vector to an i nteger
and outputs to the output por t 2.
Scramble, Parser, and Shell Mapping Subsystem
The scrambl e, parser , and shel l mappi ng computati on i s accompl i shed i n the
scrambl e, parser and shel l mappi ng subsystem. The fi gure bel ow shows the
bl ock di agram of thi s subsystem:
The l ength v34_r at e _b bi nar y vector i s i nputted i nto an S-functi on v 34t r ans .
The functi on v34t r ans i s a C code S-functi on; read the fi l e v34t r ans . c for the
i mpl ementati on detai l s. The executi on of the functi on v 34t r ans i s tr i gger ed by
the r ai si ng edge of fr ame i nformati on si gnal . The bl ock outputs the l ength
v 34_r at e_q Q
i j k
si gnal , l ength one m
i j k
si gnal and l ength three I
i j
si gnal at
the r ai si ng edge of the k i nformati on si gnal . The si gnal s Q
i j k
and m
i j k
generate
si gnal Q( n) .
Differential Encoder Subsystem
The di ffer enti al encoder subsystem maps si gnal Q( n) i nto a two-di mensi onal
si gnal v ( n) , whi ch i ncl udes i n-phase and quadrature components. The
constel l ati on used i n the mappi ng i s pr ovi ded i n the constel l ati on fi gur e i n the
l ast secti on. The I
i j
si gnal i s di vi ded i nto I 1
i j
and I 2
i j
, I 3
i j
si gnal . The I 2
i j

2
Iijlength 3
Qijklength q
mijklength 1
+
+ K
Vec to sca
converter
Demux
1
Datainput
length b
2
Frame info
1
Q(n)length 1
v34trans
Sfunction
Mux
3
k inform
V.34 M odem D ata Transm ission
4-37
and I 3
i j
si gnal i s used to generate Z( m) si gnal through di ffer ent encode. Thi s
fi gure shows the bl ock di agram of the di fferenti al encode cal cul ati on:
Rotation Subsystem
The i n-phase and quadratur e si gnal i n v ( m) i s then r otated Z( m) *90 degr ees
when k=0, or ( Z( m) +2I 1
i j
+U
0
( m) ) *90 degrees when k=1. The i mpl ementati on
of the rotati on i s shown i n the fol l owi ng bl ock di agram, whi ch pr oduces si gnal
u( m) .
1
I2ij(m)_and_I3ij(m)
Vec to sca
converter
+
+
Modulo
1/z
1
Z(m)
1
Constant
Vo(m)
6
Uo(m)
+
+
3
I1
2
+
+
Switch
box
1
u(m)
Modulo 5
switch
+
+
4
Z(m)
K
Mux
Mux
2
in_2
1
in_1
4 Exam ples
4-38
Precoder Subsystem
The precoder uses u( m) si gnal to gener ate si gnal c( n) , y ( n) , and x ( n) . The
i mpl ementati on of the pr ecoder i s shown bel ow, i n whi ch the fi l ter i s a compl ex
fi l ter . The compl ex fi l ter takes a compl ex si gnal and compl ex fi l ter coeffi ci ents.
The fi l ter outputs a fi l tered compl ex si gnal .
Nonlinear Encoder Subsystem
A nonl i near encoder takes the si gnal x ( n) and outputs si gnal . I n thi s
exampl e the nonl i near encode assumes s =0, so, . The Cal l Modem
outputs the QAM modul ated si gnal .
Ther e ar e two subsystems used i n the i mpl ementati on. They are the
synchr oni zati on pul ses si gnal gener ator and the tr el l i s code.
Synchronization Pulses Subsystem
The pul ses ar e generated i n the vector gener ator i n the fol l owi ng bl ock
di agram. The generated pul ses ar e output onl y i f the enabl e si gnal i s one
si gnal . Thi s subsystem pr oduced frame si gnal i , 4-D fr ame si gnal j , and 2-D
si gnal k. These si gnal s ar e used to synchroni ze the si mul ati on.
+

+
+
Array
function
K
Array
function
K K
K
Filter
1
x(n)
2
y(n)
3
c(n)
1
u(m)
x ' n ( )
x ' n ( ) x n ( ) =
x' n ( )
D 1
> 0
1
in_1
Edge det.
3
j signal
1
i signal
2
k signal
Demux
Pulse Demux
*
*
V.34 M odem D ata Transm ission
4-39
Trellis Code Subsystem
The most compl i cated par t i n the V.34 modem i s the tr el l i s modul ati on
i mpl ementati on. Thi s fi gur e shows the top l evel bl ock di agram of the tr el l i s
coder:
The y ( m) si gnal and c ( m) si gnal fr om the precoder ar e used to generate si gnal
Y
0
( m) and si gnal C
0
( m) respecti vel y. Based on the combi nati on of j and k i n
the transmi ssi on, a V
0
( m) si gnal i s produced as a fi xed pattern i n each fr ame.
U
0
( m) si gnal , the trel l i s coder output, i s the excl usi ve OR computati on of the
three si gnal s, Y
0
( m) , C
0
( m) , and V
0
( m) .
Symbol to Bit Conversion Subsystem. The symbol to bi t conver si on
subsystem i n the trel l i s coder subsystem maps the i n-phase and quadr atur e
si gnal i n y ( 2m) and y ( 2m+1) i nto the four bi ts si gnal Y1, Y2, Y3, and Y4. Thi s
bl ock di agr am shows the i mpl ementati on of the mappi ng:
1
y(m)
Vo(m)
3
kpulse
4
Frame
pulse
Bit inversion
pattern
2
c(m)
Modulo
encoder
Co(m)
1
Constant
Yo(m)
XOR 1
Uo(m)
5
(m+1) pulse
Demux Mux
Sca to vec
converter
Convl en Demux
Symbol to bit
convertor
80
Constant
Demux Modulo
+
+
1
y
QASK
Ademap
Modulo
1/z
QASK
Ademap
1
Y1Y4
Symtobit
convertor
Figure 10/V34
Symtobit
convertor
Figure 9/V34
4 Exam ples
4-40
The mappi ng takes pl ace i n two stages. The fi rst stage i s the mappi ng from the
i n-phase and quadr ature si gnal y( n) i nto s ( n) . The i n-phase and quadratur e
val ues ar e shi fted to the val ue where both i n-phase and quadr ature are
posi ti ve. The next pl ot shows the conver si on map.
0 1 2 3 4 5 6 7 8
0
1
2
3
4
5
6
7
8
0
1
3 4
5 6
7
0
1 2
3 4
5 6
7
Re
I
m
2
V.34 M odem D ata Transm ission
4-41
The second stage i s the mappi ng from s ( 2m) and s ( 2m+1) to Y1, Y2, Y3, and Y4.
Thi s pl ot shows thi s stage of the mappi ng:
You can gener ate these two pl ots by doubl e-cl i cki ng the cyan col or ed bl ock i n
the symbol to bi t convertor subsystem. Note that to ensure a corr ect pl ot, you
have to cl ose al l other cur rent opened fi gur es.
The si gnal s Y1, Y2, Y3, and Y4 n pr oduce Y
0
si gnal , whi ch i s used i n the
convol uti on encoder.
Modulo Encoder Subsystem. Thi s i s a di agram of the modul o encode
subsystem:
1 0 1 2 3 4 5 6 7 8
1
0
1
2
3
4
5
6
7
8
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
s(2m)
s
(
2
m
+
1
)
1
Co(m)
NOT XOR
Modulo
1/z
1
c(m)
4 Exam ples
4-42
The Bit Inversion Pattern Subsystem. The bi t i nversi on pattern subsystem
uses the fr ame si gnal and the k pul se si gnal to sel ect the bi t to be used i n as
V
0
( m) . Thi s fi gur e shows the bl ock di agram:
The Structure of Convolution Encoders. You can choose the convol uti on
encoder i n one of the thr ee encoder s, whi ch are V.34 16 convol uti on encoder s:
Thi s i s the V.34 32 state convol uti on encoder:
1
Vo(m)
[0 1 1 1 0 1 1 1 1 1 1 1 1 0 1 0]
Bit inversion patterns
Counter
Switch
box
1
k pulse
2
frame pulse
1
Constant
one
2
In2
1
Out1
1
In1
2
Out2
3
Out3
XOR XOR XOR
V.34 16 state convolution encoder
1
Out1
2
In2
1
In1
3
In3
4
In4
2
Out2
3
Out3
XOR XOR XOR XOR 5
Out5
4
Out4
V.34 32 state convolution encoder
V.34 M odem D ata Transm ission
4-43
Thi s i s the V.34 64-state convol uti on encoder .
You can assi gn the CON_CODE = 1, 2, or 3, to choose the 16-state, 32-state and
64-state convol uti on encode. Note that the si mul ati on wi l l be very sl ow i f you
choose to use the 64-state encoder because of the hi gh order states.
Answer Modem Simulation Implementation
The i mpl ementati on of the Answer Modem i s the i nver se of the i mpl ementati on
of the Cal l Modem. You can unmask the Answer Modem to see the str uctur e of
the i mpl emented Answer Modem. The top l evel of the Answer Modem i s shown
bel ow. You can go through the detai l s of the i mpl ementati on by r eadi ng the
bl ock di agr am and the parameter setti ng i n the bl ocks.
4
In4
3
In3
2
In2
1
In1
4
Out4
3
Out3
2
Out2
1
Out1
V.34 64 state convolution encoder
AND
AND
XOR
1/z 1/z
XOR
XOR
XOR
1/z
1/z
XOR
z
1
XOR
XOR
1/z
5
Out5
4 Exam ples
4-44
The fi rst i nput si gnal of the Answer Modem i s the recei ved modul ated si gnal
sent fr om the Cal l Modem. The second i nput si gnal to the Answer Modem i s the
enabl e si gnal to enabl e the synchr oni zati on pul ses. The output of thi s bl ock i s
the r ecei ved data wi th the same format as the second output as the Cal l
Modem.
You can use the output si gnal to compar e the transmi tted data. You can use a
Tri gger ed To Workspace bl ock or Tri ggered To Fi l e bl ock to save the data i n
compari ng the transmi tted data. You can connect the data i nput of the
Tri gger ed To Workspace bl ock to the output por t of the descr ambl e, par ser, and
shel l mappi ng subsystem. The tri gger si gnal shoul d be the si gnal data ready
output from the synchroni zati on pul ses subsystem.
u(n)
Descramble
Parser and
shell demapping
Mux
Rotation
Demapping
Differential
decoder
I2ij(m) and
I3ij(m)
Trellis
decode
Uo(m) before
y(n)
c(n)
Rotation2
Uo(m) after
1
in_1
QADM Mux
Nonlinear
decoder
Precoder
decoding
2
Inport
Vct rearr
Vec to sca
converter
1
out_1
k
z
k signal
j signal
Data ready
Frame begin
k
z
k
z
NOT
Synchronization
pulses

5
MATLAB
Functi on Reference
Formats and Conventions . . . . . . . . . . . . . . 5-3
Reference Tables . . . . . . . . . . . . . . . . . . 5-4
5 M A TLA B Function Reference
5-2
The MATLAB functi on l i br ary i n the Communi cati ons Tool box i s a col l ecti on
of r eady-to-use MATLAB commands for communi cati on system anal ysi s,
desi gn, and si mul ati on. Thi s chapter provi des descr i pti ons for al l functi ons i n
thi s tool box. I f appl i cabl e, the functi onal i ty of the MATLAB functi on i s the
same as the functi onal i ty of the cor respondi ng Si mul i nk bl ocks. Because of
di fferent i mpl ementati ons, the numer i cal r esul ts of a MATLAB M-fi l e functi on
may not exactl y match wi th the numeri cal resul ts of the corr espondi ng
Si mul i nk bl ock.
The MATLAB functi ons ar e di vi ded i nto these categor i es:
Sour ce, Si nk, and Err or Anal ysi s
Sour ce Codi ng
Err or-Contr ol Codi ng
Err or-Contr ol Codi ng, Lower Level Functi ons
Modul ati on and Demodul ati on
Gal oi s Fi el d Computati on Functi ons
Speci al Fi l ter s
Uti l i ti es
Note that there are fewer MATLAB functi ons than Si mul i nk bl ocks i n thi s
tool box. Some of the MATLAB functi ons combi ne several types of functi ons i nto
one functi on. For exampl e, the functi on e nc ode suppor ts l i near bl ock code,
Hammi ng code, cycl i c code, BCH code, Reed-Sol omon code, and convol uti on
code.
Form ats and C onventions
5-3
Formats and Conventions
Thi s chapter uses a di ffer ent for mat for the functi on descri pti ons. Note that not
al l of theses headi ngs are used i n each functi on:
and the fol l owi ng conventi ons:
Pur pose Provi des short conci se descr i pti ons.
Synopsi s Shows for mat of the command or functi on.
Descri pti on Descri bes what the command/functi on does and any
rul es/restr i cti ons that appl y.
Exampl es Proves exampl es of how the command/functi on can
be used.
Al gor i thm Associ ated al gor i thms and r outi nes.
See Al so Refer s you to other r el ated commands/functi ons.
Refer ence Addi ti onal r esour ces.
Monos pace Commands, functi ons names, and scr een di spl ays;
for exampl e, c onv.
I talics Book ti tl es, names of secti ons, mathemati cal nota-
ti on, and for i ntroducti on of new ter ms; for exampl e,
Communications Fundamentals.
Bold Initial Caps Key names, menu names, and i tems that ar e
sel ected from menus; for exampl e, the Enter key.
5 M A TLA B Function Reference
5-4
Reference Tables
The Communi cati ons Tool box pr ovi des ei ght mai n categori es of functi ons. The
MATLAB command hel p comcmds di spl ays an onl i ne tabl e of the mai n
categori es and thei r functi ons.
Source, Sink, and Error Analysis
bi t er r Bi t err or number and bi t err or rate computati on.
e ye s c at Eye-pattern di agram or scatter pl ot.
r andbi t Pl ace ones r andoml y i n zero vectors.
r andi nt Uni for m di stri buti on r andom i nteger gener ator.
s ymer r Symbol er ror number and symbol er ror r ate computati on.
Source Coding
c ompand -l aw or A-l aw compressor and expander cal cul ati on.
dpc mdec o Di ffer enti al pul se code modul ati on decode computati on.
dpc me nc o Di ffer enti al pul se code modul ati on encode computati on.
dpc mopt Di ffer enti al pul se code modul ati on parameter esti mati on
usi ng trai ni ng data set.
l l oyds Scal ar quanti zati on opti mi zati on usi ng tr ai ni ng data and
usi ng Ll oyd al gor i thm.
quant i z Produce quanti zati on i ndex and quanti zed output val ue.
Error-Control Coding
bchge n Produce gener ator matri x and par i ty-check matr i x for BCH
code.
bchpol y Produce generator pol ynomi al for BCH code.
c yc l gen Produce gener ator matri x and pari ty-check matri x for cycl i c
code.
c yc l pol y Produce cycl i c gener ator pol ynomi al for cycl i c code.
Reference Tables
5-5
de c ode Decodi ng computati on for a number of err or -control codi ng
techni ques, whi ch i ncl ude l i near bl ock codi ng, Hammi ng
codi ng, cycl i c codi ng, BCH codi ng, Reed-Sol omon codi ng,
and convol uti on codi ng.
enc ode Encodi ng computati on for a number of err or-contr ol codi ng
techni ques, whi ch i ncl ude l i near bl ock codi ng, Hammi ng
codi ng, cycl i c codi ng, BCH codi ng, Reed-Sol omon codi ng,
and convol uti on codi ng.
ge n2abc d Conver t a convol uti on code transfer functi on to [A, B, C, D]
form of tr ansfer functi on.
ge n2par Conver t between gener ator matri x and pari ty-check matr i x.
hammgen Produce generator matri x and par i ty-check matri x for
Hammi ng code.
ht r ut ht b Gener ate truth tabl e for Hammi ng decode.
oc t 2gen Conver t convol uti on code transfer functi on between an octal
form and a bi nar y for m.
r s dec of Use Reed-Sol omon code to decode an encoded text fi l e.
r s e nc of Use Reed-Sol omon code to encode a text fi l e.
r s pol y Produce Reed-Sol omon code generator pol ynomi al .
s i m2gen Gener ate a convol uti onal code transfer functi on fr om a Si m-
ul i nk bl ock di agr am.
s i m2l ogi Gener ate a nonl i near convol uti on code tr ansfer functi on
from a Si mul i nk bl ock di agr am.
s i m2t r ans Gener ate a convol uti on code transfer functi on fr om a Si m-
ul i nk bl ock di agr am. Thi s functi on appl i es to both l i near
and nonl i near systems.
Error-Control Coding, Lower Level Functions
bc hcor e BCH decode ker nel processi ng functi on.
bc hde co BCH decode computati on.
Error-Control Coding
5 M A TLA B Function Reference
5-6
bchenco BCH encode computati on.
bchpol y Produce BCH code generator pol ynomi al .
c onve nc o Convol uti on code encodi ng cal cul ati on.
e r r l ocp Cal cul ate er ror-l ocati on pol ynomi al for BCH and
Reed-Sol omon code.
r s c or e Reed-Sol omon decode cor e computati on par t.
r s dec o A user-i nterfaced Reed-Sol omon decode cal cul ati on.
r s dec ode Reed-Sol omon code decode cal cul ati on.
r s e nc o A user-i nterfaced Reed-Sol omon encode cal cul ati on.
r s e nc ode Reed-Sol omon code encode cal cul ati on.
v i t er bi Vi terbi convol uti on decode.
Modulation and Demodulation
ade mod Anal og demodul ati on, passband si mul ati on. Thi s functi on i s
the i nverse pr ocess of functi on amod.
ade modc e Anal og demodul ati on, baseband si mul ati on. Thi s functi on i s
the r everse of functi on amodce.
amod Anal og modul ati on, passband si mul ati on. The modul ati on
methods can be chosen from AM-DSB-SC, AM-SSB,
AM-TC, QAM, FM, and PM.
amodc e Anal og modul ati on, baseband si mul ati on. The modul ati on
methods can be chosen from AM-DSB-SC, AM-SSB,
AM-TC, QAM, FM, and PM.
apkcons t Compute/pl ot QASK ci rcl e constel l ati on.
dde mod Di gi tal demodul ati on, passband si mul ati on. Thi s functi on i s
the r everse of functi on dmod.
dde modc e Di gi tal demodul ati on, baseband si mul ati on. Thi s functi on i s
the r everse of functi on dmod.
demodmap Di gi tal demodul ati on demappi ng. Thi s functi on i s the
r everse of functi on modmap.
Error-Control Coding, Lower Level Functions
Reference Tables
5-7
dmod Di gi tal modul ati on, passband si mul ati on. The modul ati on
methods can be chosen from ASK, QASK, FSK, MSK, and
PSK.
dmodc e Baseband di gi tal modul ati on. The modul ati on methods can
be chosen from ASK, QASK, FSK, MSK, and PSK.
modmap Di gi tal modul ati on mappi ng for ASK, QASK, FSK, MSK,
and PSK.
qas kdec o Decode square constel l ati on QASK code. Thi s functi on i s
rever se computati on of qas ke nc o.
qas ke nc o Compute/pl ot QASK squar e constel l ati on.
Galois Field Computation Functions
f l x or Fl oati ng poi nt number excl usi ve OR cal cul ati on.
gf add Add two GF(2) pol ynomi al s or add two GF(2
m
) el ements.
gf di v Compute the quoti ent and remai nder of GF(2) pol ynomi al
di vi si on.
gf c onv Convol uti on cal cul ati on for two GF(2) pol ynomi al s.
gf c os et GF(2
m
) cosets cal cul ati on.
gf dec onv GF(2) pol ynomi al s deconvol uti on cal cul ati on.
gf f i l t e r GF(2) fi l teri ng computati on.
gf l i neq Compute x i n A x =b i n GF(2).
gf mi npol Fi nd mi ni mum pol ynomi al s i n GF(2
m
) .
gf mul Pol ynomi al mul ti pl i cati on i n GF(2) or el ement mul ti pl i ca-
ti on i n GF(2
m
).
gf pl us GF(2
m
) addi ti ve computati on.
gf pr e t t y GF(2) pol ynomi al presentati on.
gf pr i mc k Test GF(2) pol ynomi al i rreduci bl e and pri mi ti ve properti es.
gf pr i mdf Output defaul t GF(2) pri mi ti ve pol ynomi al at a gi ven
degree.
Modulation and Demodulation
5 M A TLA B Function Reference
5-8
gf pr i mf d Fi nd GF(2) pr i mi ti ve pol ynomi al s.
gf r ank Matri x r ank i n GF(q).
gf r epcov Gal oi s fi el d pol ynomi al r epresentati on conver si on.
gf r oot s Fi nd roots of a pol ynomi al i n extended Gal oi s fi el d.
gf s ub Subtr act a GF(2
m
) pol ynomi al fr om another.
gf t r unc GF(2) pol ynomi al tr uncati on process.
gf t upl e GF(2
m
) m-tupl e r epresentati on.
i s pr i me Check whether a number i s a pr i me number.
pr i me s Generate pri me numbers.
Special Filters
hi l bana Desi gn an anal og Hi l bert tr ansfor m fi l ter.
hi l bat f Desi gn an anal og Hi l ber t tr ansfor m fi l ter wi th compensator
for the known i nput si gnal frequency.
hi l bi i r Desi gn a di gi tal Hi l ber t I I R fi l ter.
hank2s y s Convert Hankel matri x to l i near system.
i mp2s ys FI R fi l ter to I I R fi l ter conversi on.
r cos f i r Rai sed cosi ne FI R fi l ter desi gn (l ower l evel functi on).
r cos f l t Fi l teri ng si gnal usi ng r ai sed cosi ne fi l ter.
r cos i i r Rai sed cosi ne I I R fi l ter desi gn (l ower l evel functi on).
r cos i ne Desi gn a rai sed cosi ne fi l ter.
Utilities
bi 2de Bi nary to posi ti ve deci mal i nteger conver si on.
bl kdi ag Matri x bl ock di agonal matri x.
c al l hel p Di spl ay hel p text secti ons.
Galois Field Computation Functions
Reference Tables
5-9
che cki np Check the functi on i nput and set i t to a defaul t val ue i f the
i nput i s empty or mi ssi ng.
de 2bi Posi ti ve deci mal i nteger to bi nary conver si on.
ve c 2mat Conver t vector to matr i x by a gi ven col umn number.
Utilities
ademod
5-10
ademod
5
Purpose Anal og demodul ati on, passband si mul ati on
Syntax ade mod( met hod) ;
y = ade mod( r e c _s i g, Fc, Fs , met hod, num, de n) ;
Description Functi on ade mod demodul ates an anal og modul ated si gnal i n passband. Thi s
functi on i s the i nver se process of the amod functi on. The str i ng vari abl e method
speci fi es the types of demodul ati on used. The tabl e bel ow l i sts the types of
anal og demodul ati on avai l abl e:
ade mod( met hod) pr ovi des mor e detai l ed hel p for usi ng thi s functi on wi th a
speci fi c demodul ati on method.
y = ade mod( r e c _s i g, Fc, Fs , met hod, num, de n) demodul ates the r ecei ved
si gnal r e c_s i g. The carri er frequency i s Fc (Hertz), and the sampl e frequency
i s Fs (Her tz). The ti me i nter val between two consecuti ve poi nts of y i s 1/Fs . The
var i abl e Fs can be a scal ar or a two-el ement vector . The fi rst el ement i s the
sampl e frequency; the second el ement, i f pr esent, i s the i ni ti al phase i n the
carr i er si gnal modul ati on. The i ni ti al phase i s i n radi ans, and i ts defaul t val ue
i s zero. The sampl e frequency must match the parameter s used i n the
modul ati on, but the i ni ti al phase may di ffer .
Thi s functi on uses a l owpass fi l ter i n the demodul ati on. The numerator and the
denomi nator of the l owpass fi l ter ar e speci fi ed by the i nput parameter s num and
Method Demodulation Scheme
' amds b- s c ' Ampl i tude demodul ati on, doubl e si deband suppressed
carr i er
' amds b- t c ' Ampl i tude demodul ati on, doubl e si deband wi th
tr ansmi ssi on car ri er
' ams s b' Ampl i tude demodul ati on, si ngl e si deband suppressed
carr i er
' qam' Quadr atur e ampl i tude demodul ati on
' f m' Frequency demodul ati on
' pm' Phase demodul ati on
ademod
5-11
de n r especti vel y. The sampl e ti me of the l owpass fi l ter equal s 1/Fs . When num
i s zero, empty or not gi ven, thi s functi on uses a defaul t Butter worth l owpass
fi l ter generated by:
[ num, de n] = but t er ( 5, Fc 2/Fs ) ;
method = 'amdsb-sc'
y = ade mod( r e c_s i g, Fc, Fs , ' amds b- s c' , num, de n) demodul ates the i nput
si gnal r e c _s i g usi ng the doubl e si deband suppr essed car ri er method.
y = ademod( r ec _s i g, Fc , Fs , ' amds b- s c /c os t as ' , num, den) uses a Costas l oop
i n the demodul ati on computati on.
method = 'amdsb-tc'
y = ade mod( y, Fc , Fs , ' amds b- t c' , num, den, of f s et ) demodul ates the i nput
si gnal r e c _s i g usi ng the doubl e si deband wi th transmi ssi on car ri er method.
Note that thi s method has an opti onal par ameter of f s et , whi ch i s the val ue
subtracted fr om r ec _s i g after the demodul ati on.When of f s et i s omi tted, the
functi on sets of f s et = mean( r ec _s i g) .
method = 'amssb'
y = ademod( r e c_s i g, Fc, Fs , ' ams s b' , num, de n) demodul ates the i nput si gnal
r e c _s i g usi ng the si ngl e si deband suppr essed carr i er method.
method = 'qam'
y = ade mod( r e c_s i g, Fc, Fs , ' qam' , num, de n) demodul ates the i nput si gnal
r e c _s i g usi ng the quadr atur e ampl i tude demodul ati on method. The i nput
si gnal r e c _s i g must be a vector. The output si gnal y i s a two-col umn matr i x.
The fi rst col umn i s the i n-phase si gnal and the second col umn the quadr ature
si gnal .
method = 'fm'
y = ade mod( r e c_s i g, Fc, Fs , ' f m' , num, den) demodul ates the i nput si gnal
r e c _s i g usi ng the quadr atur e fr equency demodul ati on method.
method = 'pm'
y = ade mod( r e c_s i g, Fc, Fs , ' pm' , num, den) demodul ates the i nput si gnal
r e c _s i g usi ng the quadr atur e phase demodul ati on method.
See Also amod, dmod, ddemod, amodc e, ade modce
ademodce
5-12
ademodce
Purpose Anal og demodul ati on, baseband si mul ati on wi th compl ex envel ope
Syntax ade modc e( met hod) ;
y = ade modc e( r ec _s i g, Fs , met hod, num, den) ;
Description Functi on ade modce perfor ms anal og demodul ati on i n baseband. Use thi s
functi on to demodul ate the amodc e modul ated si gnal . The str i ng vari abl e
method speci fi es the type of demodul ati on used. The tabl e bel ow l i sts the types
of anal og demodul ati on avai l abl e:
ade modc e( met hod) pr ovi des mor e detai l ed hel p for usi ng thi s functi on wi th a
speci fi c demodul ati on method.
y = ademodce ( r e c_s i g, Fs , me t hod, num, de n) demodul ates the recei ved si gnal
r ec _s i g. The si mul ati on sampl e frequency i s Fs (Her tz), and the ti me i nterval
between two consecuti ve poi nts i n y i s 1/Fs . The var i abl e Fs can be a scal ar or
a two-el ement vector. The fi rst el ement i s the sampl e frequency; the second
el ement, i f present, i s the i ni ti al phase i n the carr i er si gnal modul ati on. The
i ni ti al phase i s i n radi ans, and i ts defaul t val ue i s zero. The sampl e frequency
must match the one used i n the modul ati on, but the i ni ti al phase may di ffer.
Thi s functi on uses a l owpass fi l ter i n the demodul ati on. The numerator and the
denomi nator of the l owpass fi l ter ar e speci fi ed by the i nput parameter s num and
den r especti vel y. The sampl e ti me of the l owpass fi l ter equal s 1/Fs . When num
Method Demodulation Scheme
' amds b- s c ' Ampl i tude demodul ati on, doubl e si deband suppressed
carr i er
' amds b- t c ' Ampl i tude demodul ati on, doubl e si deband wi th
tr ansmi ssi on car ri er
' ams s b' Ampl i tude demodul ati on, si ngl e si deband suppressed
carr i er
' qam' Quadr atur e ampl i tude demodul ati on
' f m' Frequency demodul ati on
' pm' Phase demodul ati on
ademodce
5-13
i s zer o, empty or not gi ven, thi s functi on uses a defaul t l owpass fi l ter, whi ch i s
gener ated by usi ng the command:
[ num, de n] = but t er ( 5, Fc 2/Fs ) ;
method = 'amdsb-sc'
y = ade modc e( r e c _s i g, Fs , ' amds b- s c ' , num, den) demodul ates the i nput
si gnal y usi ng doubl e si deband suppr essed carr i er method.
y = ademodce ( r ec _s i g, Fs , ' amds b- s c/cos t as ' , num, den) uses Costas l oop i n
the demodul ati on computati on.
method = 'amdsb-tc'
y = ade modc e( r e c _s i g, Fs , ' amds b- t c ' , num, den, of f s e t ) demodul ates the
i nput si gnal r e c_s i g usi ng the doubl e si deband wi th tr ansmi ssi on car ri er
method. Note that thi s method has an opti onal parameter of f s e t , whi ch i s the
val ue subtr acted from y after the demodul ati on. When of f s e t i s omi tted, the
functi on sets of f s et = mean( y ) .
method ='amssb'
y = ade modc e( r e c _s i g, Fs , ' ams s b' , num, de n) demodul ates the i nput si gnal
r e c _s i g usi ng the si ngl e si deband suppr essed carr i er method.
method = 'qam'
y = ade modc e( r e c _s i g, Fs , ' qam' , num, den) demodul ates the i nput si gnal
r e c _s i g usi ng the quadr ature ampl i tude modul ati on method. The i nput si gnal
y i s a vector . The output si gnal r ec _s i g i s a two-col umn matr i x. The fi rst
col umn i s the i n-phase si gnal and the second col umn the quadrature si gnal .
method = 'fm'
r e c _s i g = ade modce ( r ec _s i g, Fs , ' f m' , num, den) demodul ates the i nput
si gnal r e c _s i g usi ng the quadr ature fr equency modul ati on method.
method = 'pm'
r e c _s i g = ade modce ( r ec _s i g, Fs , ' pm' , num, den) demodul ates the i nput
si gnal r e c _s i g usi ng the quadr ature phase modul ati on method.
See Also amod, dmod, ddemod, amodc e, ade mod
amod
5-14
amod
Purpose Anal og modul ati on, passband si mul ati on
Syntax amod( met hod) ;
y = amod( x, Fc , Fs , met hod, . . . ) ;
[ y, t ] = amod( x , Fc , Fs , met hod, . . . ) ;
Description Functi on amod performs anal og modul ati on i n passband. Thi s functi on
modul ates the i nput si gnal . The stri ng var i abl e met hod speci fi es the type of
modul ati on used. The tabl e bel ow l i sts the types of anal og modul ati on
avai l abl e:
amod( met hod) provi des mor e detai l ed hel p for usi ng thi s functi on wi th a
speci fi c modul ati on method.
y = amod( x, Fc, Fs , met hod, . . . ) modul ates the message si gnal x wi th carr i er
frequency Fc (Her tz) and sampl e fr equency Fs (Her tz). The ti me i nterval
between two consecuti ve poi nts i n x i s 1/Fs . The vari abl e Fs can be a scal ar or
a two-el ement vector. The fi rst el ement i s the sampl e frequency; the second
el ement, i f present, i s the i ni ti al phase i n the carr i er si gnal modul ati on. The
i ni ti al phase i s i n r adi ans, and i ts defaul t val ue i s zer o. By the Nyqui st
theor em, the sampl e frequency must be at l east twi ce as l ar ge as the
modul ati on car ri er fr equency.
[ y, t ] = amod( x , Fc, Fs , met hod, . . . ) outputs the computati on ti me i n t .
Method Modulation Scheme
' amds b- s c ' Ampl i tude modul ati on, doubl e si deband suppr essed
carr i er
' amds b- t c ' Ampl i tude modul ati on, doubl e si deband wi th
tr ansmi ssi on car ri er
' ams s b' Ampl i tude modul ati on, si ngl e si deband suppr essed
carr i er
' qam' Quadr atur e ampl i tude modul ati on
' f m' Frequency modul ati on
' pm' Phase modul ati on
amod
5-15
method = 'amdsb-sc'
y = amod( x, Fc , Fs , ' amds b- s c' ) modul ates the i nput si gnal x usi ng the doubl e
si deband suppressed carr i er method.
method = 'amdsb-tc'
y = amod( x, Fc , Fs , ' amds b- t c ' , of f s e t ) modul ates the i nput si gnal x usi ng
the doubl e si deband wi th tr ansmi ssi on carr i er method. of f s e t i s the val ue
subtracted fr om x pr i or to the modul ati on. When of f s e t i s omi tted, the
functi on sets of f s et = abs ( mi n( x) ) .
method = 'amssb'
y = amod( x, Fc , Fs , ' ams s b' ) modul ates the i nput si gnal x usi ng the si ngl e
si deband suppressed carr i er method. A fr equency domai n Hi l ber t transform
method i s used i n the computati on.
y = amod( x, Fc , Fs , ' ams s b' , Hi l ber t _Fi l t e r ) uses a ti me domai n Hi l ber t
fi l ter for the si ngl e si deband modul ati on cal cul ati on. Thi s functi on checks
whether there i s a mar ker i n the Hi l ber t _f i l t e r posi ti on of the par ameter
l i st, so the contents of the vari abl e Hi l be r t _Fi l t er can be anythi ng. The
functi on uses a defaul t Hi l ber t fi l ter, whi ch i t gener ates usi ng [ num, de n] =
hi l bi i r ( 1/Fs ) .
y = amod( x , Fc , Fs , ' ams s b' , num, den) uses a ti me domai n Hi l ber t fi l ter for the
si ngl e si deband modul ati on cal cul ati on. The numerator and the denomi nator
of the Hi l ber t fi l ter are speci fi ed by the i nput par ameter num and den
respecti vel y. You can use functi on hi l bi i r to desi gn the Hi l bert fi l ter .
method = 'qam'
y = amod( x , Fc , Fs , ' qam' ) modul ates the i nput si gnal x usi ng the quadratur e
ampl i tude modul ati on method. The i nput si gnal x i s a two-col umn matri x wi th
the fi rst col umn as the i n-phase si gnal and the second col umn as the
quadrature si ngl e. The output y i s a one col umn modul ated si gnal .
method = 'fm'
y = amod( x, Fc , Fs , ' f m' ) modul ates the i nput si gnal x usi ng the quadrature
frequency modul ati on method. The modul ated si gnal takes the spectrum fr om
mi n( x ) + Fc to max ( x ) + Fc .
y = amod( x, Fc, Fs , ' f m' , s ens i t i vi t y ) speci fi es the i nput si gnal sensi ti vi ty i n
the modul ati on, whi ch i s equi val ent to usi ng the command
y = amod( xs ens i t i v i t y, Fc , Fs , ' f m' ) ;
amod
5-16
method = 'pm'
y = amod( x, Fc , Fs , ' pm' ) modul ates the i nput si gnal x usi ng the quadrature
phase modul ati on method.
y = amod( x , Fc, Fs , ' pm' , s ens i t i vi t y) speci fi es the i nput si gnal sensi ti vi ty i n
the modul ati on, whi ch i s equi val ent to usi ng the command:
y = amod( x s ens i t i v i t y, Fc , Fs , ' pm' ) ;
See Also ade mod, dmod, ddemod, amodc e, ademodce
amodce
5-17
amodce
Purpose Anal og modul ati on, baseband si mul ati on wi th compl ex envel ope
Syntax amodc e( met hod) ;
y = amodc e( x, Fs , met hod, . . . ) ;
Description Functi on amodc e i s desi gned for anal og modul ati on i n baseband si mul ati on.
Thi s functi on modul ates the i nput si gnal . The stri ng var i abl e met hod speci fi es
whi ch type of modul ati on used. The tabl e bel ow l i sts the types of anal og
modul ati on avai l abl e:
amodc e( met hod) provi des mor e detai l ed hel p for usi ng thi s functi on wi th a
speci fi c modul ati on method.
y = amodc e( x, Fs , met hod, . . . ) outputs the compl ex envel op of the modul ati on
of the i nput si gnal x. The i nput and the output si gnal s have the same sampl e
frequency Fs (Her tz). The output y i s a compl ex matri x. Thi s functi on
modul ates the message si gnal x wi th carr i er fr equency Fc (Hertz) and sampl e
frequency Fs (Her tz). The ti me i nter val between two consecuti ve poi nts i n x i s
1/Fs . The var i abl e Fs can be a scal ar or a two-el ement vector. The fi rst el ement
i s the sampl e frequency; the second el ement, i f pr esent, i s the i ni ti al phase i n
the carr i er si gnal modul ati on. The i ni ti al phase i s i n r adi ans, and i ts defaul t i s
zero.
Method Modulation Scheme
' amds b- s c ' Ampl i tude modul ati on, doubl e si deband suppr essed
carr i er
' amds b- t c ' Ampl i tude modul ati on, doubl e si deband wi th
tr ansmi ssi on carr i er
' ams s b' Ampl i tude modul ati on, si ngl e si deband suppr essed
carr i er
' qam' Quadratur e ampl i tude modul ati on
' f m' Fr equency modul ati on
' pm' Phase modul ati on
amodce
5-18
method = 'amdsb-sc'
y = amodc e( x, Fs , ' amds b- s c' ) modul ates the i nput si gnal x usi ng the doubl e
si deband suppressed carr i er method.
method = 'amdsb-tc'
y = amodce ( x , Fs , ' amds b- t c ' , of f s e t ) modul ates the i nput si gnal x usi ng the
doubl e si deband wi th tr ansmi ssi on carr i er method. of f s e t i s the val ue
subtr acted from x pr i or to the modul ati on. When of f s e t i s omi tted, the
functi on sets the defaul t of f s et = abs ( mi n( x) ) .
method = 'amssb'
y = amodc e( x, Fs , ' ams s b' ) modul ates the i nput si gnal x usi ng the si ngl e
si deband suppressed carr i er method. A frequency domai n Hi l ber t transform
method i s used i n the computati on.
y = amodc e( x, Fs , ' ams s b/t i me ' ) uses a ti me domai n Hi l ber t fi l ter for the
si ngl e si deband modul ati on cal cul ati on. The functi on uses a defaul t Hi l bert
fi l ter , whi ch i t generates usi ng [ num, den] = hi l bi i r ( 1/Fs ) .
y = amodc e( x, Fs , ' ams s b/t i me ' , num, de n) uses a ti me domai n Hi l bert fi l ter
for the SSB modul ati on cal cul ati on. The numerator and the denomi nator of the
Hi l bert fi l ter ar e speci fi ed by the i nput par ameters num and den respecti vel y.
You can use functi on hi l bi i r to desi gn the Hi l bert fi l ter .
method = 'qam'
y = amodc e( x, Fs , ' qam' ) modul ates the i nput si gnal x usi ng the quadrature
ampl i tude modul ati on method. The i nput si gnal x i s a matri x wi th an even
number of col umns. The odd col umns ar e the i n-phase si gnal and the even
col umns ar e the quadratur e si ngl e. The output y has i ts number of col umn
equal to one hal f of the col umn number of x .
method = 'fm'
y = amodc e( x, Fs , ' f m' ) modul ates the i nput si gnal x usi ng quadr atur e
frequency modul ati on method. The modul ated si gnal takes the spectrum fr om
mi n( x ) + Fc to max ( x ) + Fc.
method = 'pm'
y = amodc e ( x , Fs , ' pm' ) modul ates the i nput si gnal x usi ng quadrature phase
modul ati on method.
See Also ade modc e, dmod, ddemod, amod, ademod
apkconst
5-19
apkconst
Purpose Compute and pl ot a QASK ci r cl e constel l ati on
Syntax apkcons t ( noc) ;
apkcons t ( noc, r oc ) ;
apkcons t ( noc, r oc , poc ) ;
y = apkcons t ( . . . ) ;
Description apkcons t ( noc) pl ots a QASK ci r cl e constel l ati on. The par ameter noc i s ei ther
a scal ar or a vector ; i ts el ements must be posi ti ve i nteger s. I f noc i s a scal ar,
then the functi on pl ots a si ngl e ci rcl e wi th the number of poi nts speci fi ed by
noc . I f noc i s a vector, the functi on pl ots a ci r cl e for each el ement of the vector.
The defaul t r adi us of the fi rst ci r cl e i s 1, and each fol l owi ng ci r cl e i ncr eases one
uni t i n radi us. The constel l ati on i n each ci rcl e i s evenl y di str i buted wi th the
phase of one of the constel l ati on poi nts equal to 0.
apkcons t ( noc, r oc ) speci fi es the r adi i i n each ci r cl e. The vector l ength for r oc
must be the same as the vector l ength for noc. The el ements i n r oc must be
posi ti ve numbers.
apkcons t ( noc, r oc , poc ) speci fi es the si gnatur e phase i n each ci rcl e. The
si gnature phase speci fi es the phase for one of the constel l ati on poi nts. The
vector l ength for poc must be the same as the vector l ength for noc and r oc.
y = apkcons t ( . . . ) outputs the constel l ati on i nto a compl ex vector y. The r eal
part of y i s the i n-phase component and the i magi nar y part of y i s the
quadrature component.
apkconst
5-20
Example Setti ng noc = [ 2 4 6] , apkcons t ( noc ) pl ots:
See Also dmod, modmap, ddemod, demodmap
ASK/PSK Constellation
bchcore
5-21
bchcor e
Purpose A l ow-l evel functi on that i s the core part of the BCH decode al gori thm
Syntax [ ms g, er r , cc ode] = bc hc or e( c ode, pow_di m, di m, k, t , t p) ;
Description [ ms g, er r , cc ode] = bc hc or e( c ode, pow_di m, di m, k, t , t p) decodes a BCH
codewor d vector . code i s a codewor d vector wi th i ts l ength equal to 2
pow_di m-1
.
pow_di m i s a posi ti ve i nteger that speci fi es the si ze of the Gal oi s fi el d used i n
the decodi ng computati on. k i s the number of i nformati on bi ts; t i s the BCH
err or cor recti on capabi l i ty; and t p i s a compl ete l i st of the el ements i n GF(2
di m
)
i n ascendi ng or der. Thi s functi on i s cal l ed by Si mul i nk bl ocks and MATLAB
functi ons.
Note: I n or der to r educe computati onal over head, thi s functi on does not
perform err or-checki ng. Use thi s functi on wi th cauti on.
See Also bc hde co, de code, bchpol y
bchdeco
5-22
bchdeco
Purpose BCH er ror-contr ol decodi ng
Syntax ms g = bchde co( code , k, t ) ;
ms g = bchde co( code , k, t , or d) ;
[ ms g, er r ] = bc hdec o( . . . ) ;
[ ms g, er r , cc ode ] = bc hdec o( . . . ) ;
Description ms g = bchde co( c ode , k, t ) r ecover s a message si gnal ms g from a codewor d code
usi ng BCH decodi ng. k i s the number of i nfor mati on bi ts; t i s the
err or-cor recti on capabi l i ty.
ms g = bchde co( code , k, t , or d) speci fi es the or der or d of the pr i mi ti ve
pol ynomi al r equi r ed for the BCH code.
[ ms g, er r ] = bc hdec o( . . . ) outputs the recei ved err or. When the number of
err ors i s l ar ger than t , the er ror correcti on capabi l i ty, er r i s a negati ve
number.
[ ms g, er r , cc ode ] = bc hdec o( . . . ) outputs the cor rected codewor d.
Example The code bel ow i s an exampl e of usi ng bc hdec o to pr ocess a three er ror
cor recti on BCH code:
[ pg, pm, cs , h, t ] = bchpol y( 15, 5) ;
[ h, ge n] = cy cl ge n( 15, pg) ;
ms g = r andi nt ( 100, 5) ;
c ode = enc ode( ms g, ge n) ;
c ode = r e m( c ode + r andbi t ( 100, 15, [ . 3, . 3, . 3] ) , 2) ;
[ de c, er r ] = bc hdec o( code, 5, t ) ;
See Also bchcor e , bc henco, de c ode
bchenco
5-23
bchenco
Purpose BCH er ror-contr ol encodi ng
Syntax code = bc he nc o( ms g, n, k) ;
code = bc he nc o( ms g, n, k, pg) ;
Description code = bc he nc o( ms g, n, k) encodes the k-col umn message ms g to an n-col umn
codewor d code by usi ng the BCH codi ng. ms g i s a k-col umn message; code i s an
n-col umn codewor d.
code = bc he nc o( ms g, n, k, pg) speci fi es the gener ator pol ynomi al pg for BCH
code.
Examples See the exampl e pr ovi ded i n bchde co.
See Also bc hde co, encode, dec ode
bchpoly
5-24
bchpol y
Purpose Produce a BCH code gener ator pol ynomi al
Syntax bchpol y
pg = bc hpol y( N) ;
pg = bc hpol y( m, t ) ;
[ pg, n, k] = bc hpol y ( m, t ) ;
[ pg, n, k, pm] = bc hpol y( m, t ) ;
Description bchpol y pr oduces a l i st of the codeword l ength, message l ength, and
err or-cor recti on capabi l i ty for BCH code. The codewor d l engths l i sted ar e 7, 15,
31, 63, 127, 255, and 511.
pg = bchpol y( N) outputs an ar ray pg that contai ns code wor d l engths equal or
l ar ger than N, the associ ated message l engths, and er ror -corr ecti on capabi l i ty.
The codewor d l engths, message l engths and err or-cor recti on capabi l i ti es ar e i n
the fi rst, second, and thi r d col umns of Pg r especti vel y. When N > 511, the err or
control capabi l i ty i s not l i sted.
pg = bc hpol y( m, t ) produces a BCH code generator pol ynomi al pg based on
two posi ti ve i ntegers m and t . m i s a posi ti ve i nteger l ar ger than 3 that
determi nes the l ength of the codewor d n = 2
m-1
. t deter mi nes the err or
cor recti on capabi l i ty. Thi s functi on uses the defaul t pri mi ti ve pol ynomi al
gener ated by gf pr i mdf ( m) .
m can be a bi nar y vector i nstead of a posi ti ve i nteger. I n thi s case, i t r epr esents
a pri mi ti ve pol ynomi al gener ated i n the fi el d GF(2
deg
), wher e deg i s the degr ee
of the pr i mi ti ve pol ynomi al .
[ pg, n, k] = bc hpol y ( m, t ) outputs the codewor d l ength n and the number of
i nfor mati on bi ts k.
[ pg, n, k, pm] = bc hpol y ( m, t ) outputs t he mi ni mum pol ynomi al matri x pm i n
the fi el d GF(2
m
). Each row i s a mi ni mum pol ynomi al ; pm i s a t -by-( m+1) matr i x.
See Also c yc l pol y, e ncode , de c ode
bi2de
5-25
bi 2de
Purpose Bi nary vector to posi ti ve deci mal i nteger conversi on
Syntax de = bi 2de( bi ) ;
Description de = bi 2de ( bi ) converts a bi nary vector bi to posi ti ve deci mal i nteger. When
bi i s a matr i x, the output of bi 2de i s a col umn vector wi th each el ement equal
to the deci mal representati on of the corr espondi ng row of bi .
Examples di = r andi nt ( 5, 5) ; % Ge ne r at e a 5- by - 5 r andom bi nar y mat r i x.
de = bi 2de( di ) ;
The l ast l i ne outputs a 5-by-1 vector wi th each el ement conver ted fr om a row
of the matri x di .
See Also de 2bi
biterr
5-26
bi ter r
Purpose Number of bi t err or s and bi t err or rate computati on
Syntax [ number , r at i o] = bi t er r ( x , y ) ;
[ number , r at i o] = bi t er r ( x , y , K) ;
[ number , r at i o] = bi t er r ( x , y , K, col umnwi s e ) ;
Description [ number , r at i o] = bi t er r ( x , y ) compar es the el ements i n two matr i ces x and
y . The el ements of x and y must be ei ther bi nar y numbers or i ntegers. The
number of bi ts that di ffer i s output i n number , and the rati o of number to the
total number of bi ts contai ned i n y i s output i n r at i o.
Al l el ements i n x and y shoul d be non-negati ve i ntegers. Thi s functi on
cal cul ates the total bi t number i n y by c ol umn_y r ow_yK, wher e K i s the
number of bi ts per el ement i n y. I f K i s not speci fi ed, i t defaul ts to the smal l est
i nteger sati sfyi ng MAX < 2
K
, where MAX i s the maxi mum number i n both x and y .
When x i s a matr i x and y i s a vector , or vi ce versa, thi s functi on converts the
vector i nto a matri x wi th the same number of col umns as the matr i x. The
functi on fi l l s each col umn of the new matri x wi th whatever val ue was i n the
cor respondi ng i ndex of the vector . For exampl e:
[ number , r at i o] = bi t er r ( x , y , K) speci fi es the bi t number K i n r ati o
cal cul ati on.
[ number , r at i o] = bi t er r ( x , y , K, ' col umnwi s e' ) speci fi es a col umnwi se
compar i son.
1
0
1
1 1 1 1 1
0 0 0 0 0
1 1 1 1 1

biterr
5-27
Examples The exampl e bel ow adds er ror to 10% of the el ements i n a matr i x. Each el ement
i n the matr i x i s a two-bi t number. Thi s code computes the bi t-er ror r ati o:
r ec _s i g = r andi nt ( 100, 100, 4) ;
[ i ndx , i ndy] = f i nd( r and( 100, 100) > . 9) ;
y = r andi nt ( l e ngt h( i ndx ) , 1, 4) ;
z = z er os ( 100, 100) ;
f or i = 1 : l e ngt h( i ndx )
z ( i ndx( i ) , i ndy ( i ) ) = y ( i ) ;
e nd
y = r em( x + z , 4) ;
[ num_s y m, r at _s ym] = s y mer r ( x, y)
num_s ym = 720
r at _s ym = . 072
[ num_bi t , r at _bi t ] = bi t er r ( x, y, 2) ;
num_bi t = 950
r at _bi t = . 047
The symbol err or i s 7.2% i nstead of 10% because of the natur e of the functi on
r andi nt . There i s a 25% chance of produci ng a zero el ement, whi ch i s not an
err or.
See Also s y mer r
blkdiag
5-28
bl kdi ag
Purpose Construct a bl ock di agonal matri x by the or der of i nput matri ces
Syntax out = bl kdi ag( a, b, c, d, . . . ) ;
Description out = bl kdi ag( a, b, c, d, . . . ) , where a, b, ... are matri ces, outputs a
bl ock-di agonal matr i x, such that the output matr i x out i s
The number of i nput matri ces i s l i mi ted to 26. The i nput matr i ces do not need
to be squar e, nor do they need to be of equal si ze.
See Also di ag
out
a 0 0 0 0
0 b 0 0 0
0 0 c 0 0
0 0 0 d 0
0 0 0 0
=
callhelp
5-29
cal l hel p
Purpose Cal l a hel p fi l e and di spl ay a secti on of the fi l e contents i n the MATLAB
wor kspace wi ndow
Syntax cal l hel p( f i l e_name) ;
cal l hel p( f i l e_name, st r ) ;
cal l hel p( f i l e_name, st r , addi t i on_message) ;
er r = c al l hel p( . . . ) ;
Description cal l hel p( f i l e_name) cal l s the fi l e speci fi ed i n the stri ng var i abl e f i l e_name
and di spl ays al l contents of the fi l e i n the MATLAB workspace. The stri ng i n
f i l e_name must speci fy the ful l name of the fi l e, i ncl udi ng the fi l e extensi on.
cal l hel p( f i l e_name, st r ) sear ches the contents i n f i l e_name, pri nts the
secti on between [ st r , ' _he l p_begi n' ] and [ st r ' _hel p_e nd' ] and di spl ays
i t i n the MATLAB workspace, wher e st r i s any ASCI I str i ng.
cal l hel p( f i l e_name , st r , addi t i on_message) appends the message i n the
str i ng vari abl e addi t i on_message to the di spl ay.
er r = c al l hel p( . . . ) outputs the functi on executi on er ror message. I f the
command executes successful l y, e r r =0. I f [ st r , ' _hel p_begi n' ] or
[ st r , ' hel p_end' ] i s not found, er r =2. I f the fi l e i s not found, the functi on
abandons the executi on and di spl ays an err or message.
See Also di s p
checkinp
5-30
ch ecki n p
Purpose Check i nput var i abl es and fi l l i n the defaul t val ues
Syntax [ y1, y 2, . . . , yN] = c he cki np( x 1, x2, . . . , XN, z 1, z 2, . . . , z N) ;
Description Thi s functi on checks i f the entr y x i i s empty. I f xi i s empty, thi s functi on fi l l s
the output yi wi th z i . Other wi se, the output y i has the val ue i n xi .
The number of outputs N i s l i mi ted to l ess than or equal to 10. Thi s uti l i ty
functi on i s useful for checki ng i nput val ues and fi l l i ng them wi th defaul t val ues
i f any of the i nputs i s an empty entry.
compand
5-31
compand
Purpose -l aw or A-l aw compr essor and expander cal cul ati on i n sour ce codi ng
Syntax out = c ompand( i n, par am, V) ;
out = c ompand( i n, par am, met hod) ;
Description The word compander i s a combi nati on of the ter ms compressor and expander.
Both -l aw compander s and A-l aw companders use l ogar i thm compressi on and
expansi on i n thei r respecti ve al gori thms. The -l aw compressor i s defi ned as
and the A-l aw compr essor i s defi ned as
where i s the -l aw par ameter and A i s the A-l aw par ameter. V i s the si gnal
peak val ue magni tude.
out = compand( i n, par am, V) i mpl ements a -l aw compressor wi th m speci fi ed
i n par am and the peak magni tude i n V.
out =c ompand( i n, par am, V, met hod) i mpl ements ei ther - or A-l aw compander
computati on. par am speci fi es the m or A val ue, and V the i nput si gnal peak
magni tude. The par ameter met hod speci fi es the computati on. The tabl e bel ow
l i st the avai l abl e opti ons for the met hod str i ng:
See Also quant i z , l l oy ds , dpc mopt , dpc me nc o, dpcmde c o
Method Meaning
' mu/c ompr e s s or ' -l aw compr essor
' mu/e xpander ' -l aw expander
' A/compr e s s or ' A-l aw compr essor
' A/ex pande r ' A-l aw expander
y
V 1 x V + ( ) l og
1 + ( ) l og
--------------------------------------------- x ( ) sgn =
y
A x
1 A l og +
---------------------- x ( ) sgn
V 1 A x V l og + ( )
1 A l og +
---------------------------------------------- x ( ) sgn
for 0 x A V
for A V x V <

'

=
convenco
5-32
convenco
Purpose Convol uti onal er ror -contr ol encodi ng
Syntax c ode = conv enc o( ms g, t r an_f unc ) ;
Description c ode = conv enc o( ms g, t r an_f unc ) encodes the k-col umn message ms g to
n-col umn codeword code by the convol uti onal code method. The tr ansfer
functi on matri x i s provi ded i n l i near or nonl i near format t r an_f unc, whi ch you
can generate by usi ng s i m2t r an, s i m2gen, or s i m2l ogi . The col umn number of
the i nput ms g shoul d be k. The col umn number of the output code i s n. The r ow
number of code i s r ow_numbe r _of _ms g+m, where m i s the memory l ength.
See Also e nc ode, dec ode , s i m2gen, vi t e r bi
cyclgen
5-33
cycl gen
Purpose Produce a cycl i c code generator matri x and a par i ty-check matr i x
Syntax h = c yc l gen( n, p) ;
h = c yc l gen( n, p, opt ) ;
[ h, g] = c yc l gen( . . . ) ;
[ h, g, m, k] = c yc l ge n( . . . ) ;
Description h = c yc l gen( n, p) pr oduces the par i ty-check matri x for a gi ven l ength n
codewor d and generates a cycl i c pol ynomi al p. Pol ynomi al p can gener ate a
cycl i c code onl y i f p i s a factor of the pol ynomi al X
n-1
. The number of i nfor mati on
bi ts i s
k = n m, where m i s the degree of pol ynomi al p. The pari ty-check matri x i s
an m-by-n matr i x.
h = c yc l gen( n, p, opt ) pr oduces the par i ty-check matr i x based on the
i nstructi on gi ven i n opt . When opt = ' s ys t e m' , the functi on generates a
systemati c matri x for cycl i c code.
[ h, g] = cy cl ge n( . . . ) pr oduces the gener ator matr i x g and the pari ty-check
matr i x h. The par i ty-check matr i x i s a k-by-n matri x, wher e k = n m.
[ h, g, m, k] = c yc l ge n( . . . ) outputs the di mensi on i nfor mati on n and k.
See Also cy c l pol y
cyclpoly
5-34
cycl pol y
Purpose Produce a cycl i c code generator pol ynomi al
Syntax p = c yc l pol y( n, k) ;
p = c yc l pol y( n, k, f d_f l ag) ;
Description p = c yc l pol y( n, k) fi nds a nontri vi al cycl i c generator pol ynomi al for a gi ven
codewor d l ength n and number of i nformati on bi ts k.
p = c yc l pol y ( n, k, f d_f l ag) fi nds a cycl i c gener ator pol ynomi al wi th speci fi ed
properti es for a gi ven codeword l ength n and number of i nfor mati on bi ts k.
f d_f l ag i s a stri ng var i abl e that al l ows you to sel ect what ki nd of cycl i c
pol ynomi al to use i n the cycl i c code computati on. The tabl e bel ow l i sts the
opti ons avai l abl e:
When the output p i s empty, there i s no pr i mi ti ve pol ynomi al found for the
gi ven condi ti ons.
See Also c yc l gen
fd_flag Meaning
' mi n' Fi nd cycl i c gener ator pol ynomi al wi th mi ni mum degr ee
' max' Fi nd cycl i c generator pol ynomi al wi th maxi mum degree
' ex h' Per for m an exhausti ve search for al l pri mi ti ve
pol ynomi al s of the gi ven degree
L Fi nd al l cycl i c gener ator pol ynomi al s wi th L terms
ddemod
5-35
ddemod
Purpose Di gi tal demodul ati on, passband si mul ati on
Syntax dde mod( met hod) ;
x= ddemod( y , Fc, Fd, Fs , met hod, . . . ) ;
[ x , t ] = ddemod( y , Fc , Fd, Fs , met hod, . . . ) ;
Description Functi on dde mod r ecovers a di gi tal si gnal from a si gnal modul ated by dmod. The
demodul ati on method, speci fi ed by the str i ng vari abl e method, must
cor respond wi th the type of modul ati on used i n dmod. The tabl e bel ow l i sts the
types of demodul ati on avai l abl e:
dde mod( met hod) provi des mor e detai l ed hel p on speci fi c demodul ati on
methods.
r e c _s i g = dde mod( y , Fc, Fd, Fs , met hod, . . . ) recover s the modul ated di gi tal
si gnal . r e c_s i g, the di gi tal si gnal to be r ecover ed, has frequency Fd. The
carr i er fr equency for the modul ati on i s Fc (Her tz); the si mul ati on sampl e
frequency i s Fs (Her tz). Fs /Fd must be a posi ti ve i nteger . When i nput y i s a
matr i x, each col umn of y i s pr ocessed i ndependentl y. The row si ze of the output
matr i x r e c_s i g i s:
Fd/Fs r ow_s i z e _of _y
The ti me i nterval between two consecuti ve poi nts of i nput y i s 1/Fs , and the
ti me i nter val between two consecuti ve poi nts of output r ec _s i g i s 1/Fd. The
ti me i nter val between two consecuti ve poi nts i n x i s 1/Fs . The var i abl e Fs can
be a scal ar or a two-el ement vector . The fi r st el ement i s the sampl e frequency;
Method Modulation Scheme
' as k' Ampl i tude shi ft-keyi ng modul ati on
' f s k' Frequency shi ft-keyi ng modul ati on
' ms k' Mi ni mum shi ft-keyi ng modul ati on
' ps k' Phase shi ft-keyi ng modul ati on
' qas k' Quadratur e ampl i tude shi ft-keyi ng modul ati on
' s ampl e ' Sampl i ng Fd frequency si gnal to Fs fr equency si gnal
ddemod
5-36
the second el ement, i f pr esent, i s the i ni ti al phase i n the car ri er si gnal . The
i ni ti al phase i s i n r adi ans, and i ts defaul t i s zero.
For best resul ts, Fs > Fc > Fd i s recommended.
The ti me i nterval between two deci si on poi nts i s 1/Fd. The defaul t offset for the
deci si on poi nt i s 0. When Fd i s a two-el ement vector, the second el ement i n Fd
i s the deci si on ti mi ng offset. Thi s functi on measures the di stance of the
recei ved si gnal to al l possi bl e di gi ts i n the codi ng scheme. The di gi t cl osest to
the recei ved si gnal poi nt i s sel ected as the output di gi t.
A di gi tal demodul ati on i ncl udes two parts: anal og demodul ati on and anal og to
di gi tal demappi ng. To obtai n the i ntermedi ate resul t, you can br eak the
command:
r ec _s i g = ddemod( y , Fc, Fd, Fs , met hod, . . . )
i nto two commands:
z = dde mod( y , Fc, Fd, Fs , [ met hod, ' /nomap' ] , . . . ) ;
r ec _s i g = de modmap( z , Fd, Fs , met hod, . . . ) ;
I n thi s exampl e, the swi tch '/nomap' di sabl es the mappi ng pr ocess. The
i ntermedi ate si gnal z has a sampl e fr equency Fs .
The functi on pl ots an eye-pattern di agram when the str i ng ' /ey e' i s appended
to the var i abl e met hod; appendi ng the str i ng ' /s cat t er ' to the var i abl e
met hod produces a scatter pl ot. The functi on provi des onl y one pl ot i f both ' /
e ye ' and ' /s c at t er ' ar e speci fi ed. You can use the opti on ' /s c at t er ' wi th the
' as k' and ' qas k' methods onl y.
method = 'ask'
r ec _s i g = dde mod( y , Fc, Fd, Fs , ' as k' , M) demodul ates an M-ary ASK
modul ated si gnal . The M-ary number for the M-ar y ASK i s M. The output
di gi tal si gnal i s an i nteger i n the range [0, M1]. The functi on uses a defaul t
l owpass fi l ter; the numerator num and denomi nator den are generated by usi ng
the command [ num, den] = but t e r ( 5, Fc 2/Fs ) .
r ec _s i g = dde mod( y, Fc, Fd, Fs , ' as k' , M, num, de n) speci fi es the denomi nator
and numerator of the demodul ati on l owpass fi l ter.
ddemod
5-37
method = 'psk'
r e c _s i g = dde mod( y , Fc, Fd, Fs , ' ps k' , M) demodul ates an M-ary PSK
modul ated si gnal . The M-ary number for the M-ary PSK i s M. The output di gi tal
si gnal i s an i nteger i n the r ange [ 0, M1] . Thi s functi on uses the cor rel ati on
PSK demodul ati on method.
method = 'qask'
Thi s method suppor ts thr ee di fferent constel l ati ons: square, ci rcl e, and
ar bi trary constel l ati ons.
The square constel l ati on has a squar e shape, whi ch i s determi ned by the M-ary
number M. Usual l y, M equal s 2
K
, where K i s a posi ti ve i nteger . The maxi mum
i n-phase and quadr ature val ues i n the constel l ati on ar e:
A ci r cl e constel l ati on i s defi ned by usi ng three equal l ength vector s. These
three vectors ar e:
noc (Number of symbol s on each ci rcl e),
r oc (Radi i on each ci rcl e), and
poc (Phase shi ft on each ci r cl e, i n r adi ans).
The M-ary number of thi s bl ock equal s the summati on of al l el ements i n noc .
Let noc be [N
1
, N
2
,..., N
K
]; r oc be [R
1
, R
2
,..., R
N
]; and poc be [P
1
, P
2
,..., P
K
]. Then the
i th ci r cl e has N
i
el ements, i = 1, ..., N. The N
i
poi nts are evenl y di stri buted on
the i th ci rcl e wi th thei r radi i equal R
i
. One of the poi nts on the i th ci r cl e has
M=2
K
In-phase Quadrature
2 1 1
4 1 1
8 3 1
16 3 3
32 5 5
64 7 7
128 11 11
256 15 15
ddemod
5-38
phase P
i
. I n another wor ds, the N
i
poi nts on the ci rcl e ar e l ocated at the
posi ti ons:
The el ements i n the vectors noc and r oc must be posi ti ve. I n any of the three
vectors, the el ements can be repeated. For a corr ect demappi ng, the el ements
shoul d have no repeati ng poi nts.
You can defi ne an arbi trar y constel l ati on by usi ng two of same l ength vectors.
The two vector s are the i n-phase component, i n_phas e , and the quadratur e
component, quad. The M-ar y number of the mappi ng equal s the l ength of the
vectors. The i n-phase val ue and the quadr atur e val ue of symbol i , i = 0,
1, . . . , M1, are defi ned i n the (i +1)th el ement i n the i n_phas e vector and i n
the quad vector respecti vel y.
I n al l the constel l ati ons di scussed i n thi s secti on, thi s functi on r equi r es the use
of a l owpass fi l ter. I n al l cases wher e num and de n, the numer ator and
denomi nator of the fi l ter s tr ansfer functi on, are not speci fi ed, the functi on
gener ates a defaul t fi l ter tr ansfer functi on by usi ng the command:
[ num, de n] = but t er ( 5, Fc 2/Fs ) .
You can overr i de the defaul t by speci fyi ng num and den i n the functi on
par ameter l i st.
r ec _s i g = dde mod( y , Fc, Fd, Fs , ' qas k' , M) demodul ates a square
constel l ati on QASK modul ated si gnal . The M-ary number for QASK i s M. The
output di gi tal si gnal i s i n r ange [ 0, M1] .
r ec _s i g = dde mod( y , Fc, Fd, Fs , ' qas k' , M, num, den) speci fi es the numer ator
and denomi nator of the demodul ati on l owpass fi l ter .
r ec _s i g = dde mod( y , Fc, Fd, Fs , ' qas k/ar b' , i n_phas e , quad) demodul ates a
QASK modul ated si gnal by means of a user-defi ned arbi trar y constel l ati on.
The i n-phase quadratur e components ar e defi ned i n the var i abl es i n_phas e
and quad respecti vel y. The vector s l ength of i n_phas e and quad must be the
same; the l ength i s the M-ary number for the QASK.
R
i
e
j P
i
R
i
e
j P
i
2
N
i
------ - +
,
_
...
R
i
e
j P
i
2 N
i
1 ( )
N
i
---------------------------- +
,
_
ddemod
5-39
r e c _s i g = dde mod( y , Fc, Fd, Fs , ' qas k/ar b' , i n_phas e, quad, num, de n)
speci fi es the numerator and denomi nator of the demodul ati on l owpass fi l ter.
r e c _s i g = dde mod( y , Fc, Fd, Fs , ' qas k/c i r cl e ' , noc, r oc, poc ) demodul ates a
QASK modul ated si gnal usi ng a ci r cl e constel l ati on. The number of poi nts on
the ci rcl es (noc ), radi i of the ci r cl es (r oc), and the phase of the poi nts of the
ci r cl e (poc) defi ne the QASK constel l ati on. The vector l engths of noc, r oc , and
poc must be equal .
r e c _s i g = dde mod( y , Fc, Fd, Fs , ' qas k/c i r c l e ' , noc, r oc , poc , num, de n)
speci fi es the numerator and denomi nator of the demodul ati on l owpass fi l ter.
method = 'fsk'
r e c _s i g = dde mod( y , Fc, Fd, Fs , ' f s k' , M, t one ) demodul ates a FSK
modul ated si gnal usi ng the coherence method. The M-ar y number for QASK i s
M. The tone space between two successi ve fr equenci es i s defi ned i n t one .
r e c _s i g = dde mod( y , Fc, Fd, Fs , ' f s k/nonc o' , M, t one ) demodul ates a FSK
modul ated si gnal usi ng the noncoher ence method.
method = 'msk'
r e c _s i g = ddemod( y , Fc , Fd, Fs , ' ms k' ) demodul ates the i nput si gnal y usi ng
the mi ni mum shi ft-keyi ng method. The el ements i n the output vector r ec _s i g
ar e bi nary number s. The tone space, i .e., the frequency separ ati on between
successi ve frequenci es, defaul ts to t one = Fd.
method = 'psk'
r e c _s i g = dde mod( y , Fc, Fd, Fs , ' ps k' , M) demodul ates the i nput si gnal y
usi ng phase shi ft-keyi ng method. The M-ary number i s speci fi ed by M.
method = 'sample'
r e c _s i g = dde mod( y , Fc, Fd, Fs , ' s ampl e ' ) downsampl es i nput si gnal y fr om
the i nput sampl e r ate Fs to the output sampl e rate Fd. Fs / Fd must be a
posi ti ve i nteger.
See Also dmod, dmodc e, ddemodce , modmap, de modmap
ddemodce
5-40
ddemodce
Purpose Di gi tal demodul ati on, baseband si mul ati on wi th compl ex envel ope
Syntax dde modc e( met hod) ;
r ec _s i g = dde modce ( y , Fd, Fs , met hod, . . . ) ;
Description Functi on dde modce i s desi gned to r ecover a di gi tal si gnal that was modul ated
by usi ng dmodc e. Thi s functi on assumes the i nput si gnal i s a compl ex var i abl e
that contai ns the compl ex envel ope of the modul ated si gnal . The demodul ati on
method, speci fi ed by the stri ng vari abl e method, must corr espond wi th the type
of modul ati on used i n dmodce . The tabl e bel ow l i sts the types of demodul ati on
avai l abl e:
Note that ' s ampl e ' i s not a modul ati on scheme, but a uti l i ty that r esampl es
the i nput si gnal . dde modce ( met hod) pr ovi des more detai l ed hel p on speci fi c
demodul ati on methods.
r ec _s i g = dde mod( y , Fd, Fs , met hod, . . . ) r ecovers the modul ated di gi tal
si gnal . r e c_s i g, the di gi tal si gnal to be r ecover ed, has frequency Fd. The
si mul ati on sampl e fr equency i s Fs (Hertz). Fs /Fd must be a posi ti ve i nteger .
When i nput y i s a matr i x, each col umn of y i s processed i ndependentl y. The row
si ze of the output matr i x r e c_s i g i s:
Fd/Fs r ow_s i z e _of _y
The ti me i nterval between two consecuti ve poi nts of i nput y i s 1/Fs , and the
ti me i nter val between two consecuti ve poi nts of output r ec _s i g i s 1/Fd. The
Method Modulation Scheme
' as k' M-ar y ampl i tude shi ft-keyi ng modul ati on
' f s k' M-ar y frequency shi ft-keyi ng modul ati on
' ms k' Mi ni mum shi ft-keyi ng modul ati on
' ps k' M-ar y phase shi ft-keyi ng modul ati on
' qas k' Quadr atur e ampl i tude shi ft-keyi ng modul ati on
' s ampl e ' Downsampl i ng Fd frequency si gnal to Fs frequency
si gnal uti l i ty
ddemodce
5-41
var i abl e Fs can be a scal ar or a two-el ement vector . The fi r st el ement i s the
sampl e frequency, and the second el ement, i f pr esent, i s the i ni ti al phase.
The ti me i nterval between two deci si on poi nts i s 1/Fd, and the defaul t offset for
the deci si on poi nt i s 0. When Fd i s a two-el ement vector , the second el ement i n
Fd i s the deci si on ti mi ng offset.
Thi s functi on measures the di stance of the recei ved si gnal to al l possi bl e di gi ts
i n the codi ng scheme and sel ects the di gi t cl osest to the r ecei ved si gnal poi nt as
the output di gi t.
A di gi tal demodul ati on i ncl udes two parts: anal og demodul ati on and anal og to
di gi tal demappi ng. To obtai n the i ntermedi ate resul t, you can br eak the
command:
r ec _s i g = ddemodce ( y , Fd, Fs , met hod, . . . )
i nto two commands:
z = dde modc e ( y , Fd, Fs , [ met hod, ' /nomap' ] , . . . ) ;
r ec _s i g = de modmap( z , Fd, Fs , met hod, . . . ) ;
I n thi s exampl e, the swi tch ' /nomap' i s appended to the method to di sabl e the
mappi ng pr ocess. The i ntermedi ate si gnal z has a sampl e fr equency Fs .
The functi on pl ots an eye-pattern di agram when the str i ng '/ey e' i s appended
to the vari abl e met hod; appendi ng the stri ng '/s c at t e r ' to the var i abl e met hod
produces a scatter pl ot. The functi on provi des onl y one pl ot i f both '/ey e' and
'/s c at t er ' are speci fi ed. You can use the opti on '/s cat t e r ' wi th the 'as k' and
'qas k' methods onl y.
method = 'ask'
r e c _s i g = dde modce ( y , Fd, Fs , ' as k' , M) demodul ates an ASK modul ated
si gnal . The M-ary number for ASK i s M. The output di gi tal si gnal i s an i nteger
i n the r ange [0, M1]. Ther e i s no defaul t l owpass fi l ter used i n thi s method
format.
r e c _s i g = dde modce ( y , Fd, Fs , ' as k' , M, num, den) speci fi es the denomi nator
and numerator of an opti onal demodul ati on l owpass fi l ter .
method = 'psk'
r e c _s i g = dde modce ( y , Fd, Fs , ' ps k' , M) demodul ates a PSK modul ated
si gnal . The M-ary number for PSK i s M. The output di gi tal si gnal i s an i nteger
ddemodce
5-42
i n the r ange [0, M1]. Thi s functi on uses the corr el ati on PSK demodul ati on
method.
method = 'qask'
Thi s functi on supports thr ee di ffer ent constel l ati ons: squar e, ci rcl e, and
ar bi tr ary constel l ati ons.
The square constel l ati on has a squar e shape, whi ch i s determi ned by the M-ary
number M. Usual l y, M equal s 2
K
, where K i s a posi ti ve i nteger . The maxi mum
i n-phase and quadr ature val ues i n the constel l ati on ar e:
A ci r cl e constel l ati on i s defi ned by usi ng three equal l ength vector s. These
three vector s are:
noc (Number of symbol s on each ci r cl e),
roc (Radi i on each ci rcl e), and
poc (Phase shi ft on each ci r cl e, i n r adi ans).
The M-ary number of thi s bl ock equal s the summati on of al l el ements i n noc .
Let noc be [N
1
, N
2
,..., N
K
]; r oc be [R
1
, R
2
,..., R
N
]; and poc be [P
1
, P
2
,..., P
K
]. Then the
i th ci r cl e has N
i
el ements, i = 1, ..., N. The N
i
poi nts are evenl y di stri buted on
the i th ci rcl e wi th thei r radi i equal R
i
. One of the poi nts on the i th ci r cl e has
M=2
K
In-phase Quadrature
2 1 1
4 1 1
8 3 1
16 3 3
32 5 5
64 7 7
128 11 11
256 15 15
ddemodce
5-43
phase P
i
. I n another wor ds, the N
i
poi nts on the ci rcl e ar e l ocated at the
posi ti ons:
The el ements i n the vectors noc and r oc must be posi ti ve. I n any of the three
vectors, the el ements can be repeated. For a corr ect demappi ng, the el ements
shoul d have no repeati ng poi nts.
You can defi ne an arbi trar y constel l ati on by usi ng two of same l ength vectors.
The two vector s are the i n-phase component, i n_phas e , and the quadrature
component, quad. The M-ar y number of the mappi ng equal s the l ength of the
vectors. The i n-phase val ue and the quadr atur e val ue of symbol i , i = 0,
1, . . . , M1, are defi ned i n the (i +1)th el ement i n the i n_phas e vector and i n
the quad vector r especti vel y.
I n al l the constel l ati ons di scussed i n thi s secti on, thi s functi on r equi r es the use
of a l owpass fi l ter. I n al l cases wher e num and de n, the numer ator and
denomi nator of the fi l ter s tr ansfer functi on, ar e not speci fi ed, the functi on
gener ates a defaul t fi l ter tr ansfer functi on by usi ng the command:
[ num, de n] = but t er ( 5, Fc 2/Fs )
You can overr i de the defaul t by speci fyi ng num and den i n the functi on
parameter l i st.
r e c _s i g = ddemodce ( y , Fd, Fs , ' qas k' , M) demodul ates a squar e constel l ati on
QASK modul ated si gnal . The M-ary number for QASK i s M. The output di gi tal
si gnal i s i n the r ange [0, M1].
r e c _s i g = dde modc e( y , Fd, Fs , ' qas k' , M, num, den) speci fi es the denomi nator
and numerator of the demodul ati on l owpass fi l ter.
r e c _s i g = dde modce ( y , Fd, Fs , ' qas k/ar b' , i n_phas e , quad) demodul ates a
QASK modul ated si gnal wi th a user-defi ned arbi trar y constel l ati on. The
i n-phase component and the quadratur e component are defi ned i n the
var i abl es i n_phas e and quad r especti vel y. The vector l engths of i n_phas e and
quad must be equal ; the l ength equal s the M-ary number used i n the QASK
modul ati on.
R
i
e
j P
i
R
i
e
j P
i
2
N
i
------- +
,
_
... R
i
e
j P
i
2 N
i
1 ( )
N
i
---------------------------- +
,
_
ddemodce
5-44
r ec _s i g = dde modce ( y , Fd, Fs , ' qas k/ar b' , i n_phas e , quad, num, de n)
speci fi es the denomi nator and numerator of the demodul ati on l owpass fi l ter .
r ec _s i g = dde modce ( y , Fd, Fs , ' qas k/ci r cl e' , noc , r oc, poc) demodul ates a
QASK modul ated si gnal usi ng ci rcl e constel l ati on. The number on ci rcl e (noc),
ampl i tude on ci rcl e (r oc ) and the phase on ci rcl e (poc ) defi ne the QASK
constel l ati on. The vector s l ength of noc , r oc and poc must be of equal l ength.
r ec _s i g = dde modce ( y , Fd, Fs , ' qas k/ci r cl e' , noc , r oc, poc, num, den)
speci fi es the denomi nator and numerator of the demodul ati on l owpass fi l ter .
method = 'fsk'
r ec _s i g = ddemodce ( y , Fd, Fs , ' f s k' , M, t one) demodul ates a FSK modul ated
si gnal usi ng coherence method. The M-ary number for QASK i s M. The tone
space between two successi ve fr equenci es i s defi ned i n t one .
r ec _s i g = dde modce ( y , Fd, Fs , ' f s k/nonc o' , M, t one) demodul ates a FSK
modul ated si gnal usi ng noncoherence method.
method = 'msk'
r ec _s i g = dde modce ( y , Fd, Fs , ' ms k' ) demodul ates the i nput si gnal y usi ng
mi ni mum shi ft-keyi ng method. The el ements i n the output vector x are bi nar y
numbers. The tone space, i .e., the fr equency separ ati on between successi ve
frequenci es, defaul ts to t one = Fd.
method = 'psk'
r ec _s i g = dde modce ( y , Fd, Fs , ' ps k' , M) modul ates the i nput si gnal y usi ng
phase shi ft-keyi ng method. The M-ary number i s defi ned i n M.
method = 'sample'
r ec _s i g = dde modce ( y , Fd, Fs , ' s ampl e' ) conver ts sampl i ng rate Fs i nput
si gnal y to sampl i ng rate Fd output si gnal x , where Fs > Fd and Fs / Fd i s a
posi ti ve i nteger.
See Also dmod, dmodc e , ddemod, modmap, de modmap
de2bi
5-45
de2bi
Purpose Posi ti ve deci mal i nteger to bi nar y row vector conversi on
Syntax bi = de 2bi ( de ) ;
bi = de 2bi ( de , n) ;
Description bi = de2bi ( de ) conver ts a posi ti ve deci mal number de to a bi nary r ow vector .
When de i s a vector , the output of de 2bi , bi , i s a matr i x. Each r ow of bi i s the
bi nary conver si on of the cor respondi ng el ement i n de.
bi = de 2bi ( de , n) speci fi es the l ength of each r ow bei ng n.
Examples be = r andi nt ( 5, 1, [ 0 3] ) ; % Gener at e a 5- by- 1 r andom bi nar y
% mat r i x .
bi = de 2bi ( de, 3) ;
The l ast l i ne outputs a 5-by-3 matri x i n whi ch each row i s the bi nary conversi on
of each deci mal el ement of de .
See Also bi 2de
decode
5-46
decode
Purpose Er ror-contr ol decodi ng
Syntax ms g = dec ode( c ode, N, K) ;
ms g = dec ode( c ode, N, K, met hod, opt 1, opt 2, opt 3, opt 4) ;
[ ms g, er r ] = de code ( . . . ) ;
[ ms g, er r , cc ode ] = de code ( . . . ) ;
[ ms g, er r , cc ode , c er r ] = de code ( . . . ) ;
Description dec ode i s used to r ecover the or i gi nal message fr om a r ecei ved codewor d usi ng
err or-control decodi ng. The decode method and i ts par ameters must exactl y
match the method that was used i n encodi ng the ori gi nal si gnal .
ms g = dec ode( c ode, N, K) decodes bi nary messages usi ng Hammi ng decodi ng
techni que. The codeword l ength i s N and the number of i nformati on bi ts i s K.
The for mat of code can be ei ther a vector or an N col umn matr i x. A Hammi ng
code has a codewor d l ength 2
M
1, wher e M i s an i nteger number gr eater than
or equal to 3. The number of i nfor mati on bi ts i s 2
M
N1. Hammi ng code i s a
si ngl e error -corr ecti on code.
ms g = dec ode( c ode, N, K, met hod, opt 1, opt 2, opt 3, opt 4) decodes the
codewor d usi ng an err or -control codi ng method speci fi ed by the stri ng vari abl e
met hod. I n al l cases, the number of i nfor mati on bi ts i s K and the codeword
l ength i s N, wher e N and K ar e i ntegers and N>K. opt 1 to opt 4 ar e extr a opti onal
par ameters used i n some of the methods:
Method Decode Scheme
' hammi ng' Hammi ng code. opt 1=N, the codewor d l ength. opt 2=K,
the number of i nformati on bi ts. opt 1 can al so be used to
speci fy the pri mi ti ve pol ynomi al . The functi on uses a
defaul t pr i mi ti ve pol ynomi al i f opt 1 i s not speci fi ed.
opt 2 to opt 4 ar e not used i n thi s method.
' l i ne ar Li near bl ock code. opt 1=N, the codewor d l ength. opt 2=K,
the number of i nformati on bi ts. opt 1 must be used to
speci fy the pari ty-check matr i x. opt 2 speci fi es the
err or-detecti on l ogi c ci r cui t; when opt 2 i s not pr ovi ded,
thi s functi on defaul ts to si ngl e-err or-corr ecti on l ogi c.
opt 3 to opt 4 ar e not used.
decode
5-47
Method Decode Scheme
cy cl i c Cycl i c code. opt 1 i s the generator pol ynomi al , whi ch you
must speci fy. Use functi on c yc l pol y to choose a sui tabl e
cycl i c pol ynomi al . opt 2 speci fi es the er ror detecti on
l ogi c; when opt 2 i s not provi ded, thi s functi on defaul ts
to si ngl e er ror-cor recti on l ogi c. opt 3 and opt 4 are not
used.
bc h Bi nary BCH code. opt 1 speci fi es the er ror-corr ecti on
capabi l i ty. I f you do not speci fy opt 1, thi s functi on uses
functi on bc hpol y to fi nd the er ror-cor recti on capabi l i ty.
opt 2 speci fi es a BCH code gener ator pol ynomi al . I f you
do not speci fy opt 2, thi s functi on uses a defaul t
generator pol ynomi al . Use the command bc hpol y to
vi ew the val i d (N, K) pai rs for BCH code. opt 3 and opt 4
ar e not used.
r s Reed-Sol omon code. The codewords for RS code have
l ength equal to 2
M
1, wher e M i s an i nteger gr eater
than or equal to 3. The er ror-cor recti on capabi l i ty i s
T=f l oor ( ( NK) /2) . Set NK to an even number. opt 1
contai ns a l i st of al l el ements i n GF(2
M
). I f you do not
speci fy opt 1, thi s functi on computes al l the el ements of
GF(2
M
) before proceedi ng to the encode cal cul ati ons.
opt 2 thr ough opt 4 are not used.
decode
5-48
The message si gnal i n c ode can be a bi nary vector or an L-col umn matri x.
Except for the ' r s ' method, L = N, the codewor d l ength. I n the ' r s ' method,
L = M, wher e M i s an i nteger gr eater than or equal to 3, and the codewor d l ength
N=2
M
1.
Thi s functi on al so supports deci mal i nteger codi ng. Thi s means that the
message si gnal i n c ode can be a non-negati ve i nteger i n the range of [0, 2
L
1].
I n thi s case, you have to append ' /de ci mal ' to the str i ng var i abl e met hod. For
exampl e, ' bc h' i s equi val ent to ' bc h/bi nar y ' , but ' bch/de ci mal ' means that
the data i n code i s a deci mal i nteger . Except for the 'r s ' method, the output ms g
i s a vector when usi ng the deci mal method.
For the ' r s ' method, you have the opti on to speci fy ' r s /power ' . Thi s tel l s the
functi on that the code i s a r epr esentati on i n the power for mat i n GF(2
M
). The
data range i n the power format i s I nf to 2
M
2. (Note codewor d l ength
N = 2
M
1). I n both 'r s /dec i mal ' and 'r s /power ' case, ms g can be a vector or an
N col umn matr i x, wher e N i s the codeword l ength. I n the bi nar y case, code can
be ei ther a vector or an M col umn matri x.
Method Decode Scheme
conv ol Convol uti onal code usi ng the Vi ter bi al gori thm to
decode. You must speci fy opt 1, whi ch can be the l i near,
nonl i near, or octal form of the transfer functi on matr i x
of the convol uti onal code. Read the descri pti on for
gen2abc d for a defi ni ti on of the octal for m. opt 2 i s an
i nteger that speci fi es the memor y l ength. When opt 2 i s
a nonposi ti ve i nteger or i s not speci fi ed, thi s functi on
uses an unl i mi ted memor y l ength scheme. opt 3
speci fi es the transfer probabi l i ty. The tr ansfer
pr obabi l i ty i s defi ned usi ng a thr ee r ow matri x i n thi s
tool box. Refer to the descri pti on of functi on v i t e r bi for
a defi ni ti on of the transfer probabi l i ty. When opt 3 i s
not speci fi ed or i s not a thr ee r ow matri x, thi s functi on
uses the har d deci si on decodi ng scheme. opt 4 i s a
nonnegati ve i nteger that speci fi es the fi gur e number
for pl otti ng the trel l i s pl ot. I f opt 40 or i f i t i s omi tted,
thi s functi on suppresses the trel l i s fi gure pl ot.
decode
5-49
The output ms g contai ns the r ecover ed message. The format of ms g matches the
format of code. When code i s an N-col umn matr i x, the output ms g i s a K-col umn
matr i x.
When the format of the i nputted code i s not the same as the output of the
functi on encode, thi s functi on stops processi ng.
[ ms g, er r ] = dec ode ( . . . ) i ndi cates the number of er rors detected i n the
decodi ng pr ocess. I f the el ement i n e r r i s a negati ve number, i t means that
more er ror s occurr ed dur i ng pr ocessi ng than the err or-cor recti on al gor i thm
was capabl e of handl i ng. I n the 'conv ol ' method, i nstead of the number of
err ors cor rected, the parameter e r r contai ns the metr i c cal cul ati ons used i n
the decodi ng deci si on process.
[ ms g, er r , cc ode] = de code ( . . . ) outputs the cor rected code i n c code .
[ ms g, er r , cc ode, c er r ] = dec ode ( . . . ) outputs the err ors cor respondi ng to
each r ow of cc ode . I n the 'c onvol ' method, i nstead of the number of err ors
cor rected, the parameter cer r contai ns the metri c cal cul ati ons used i n the
decodi ng deci si on process.
See Also enc ode, bchpol y, bchde c o, r s pol y, r s de co, c yc l pol y, cy cl ge n, s i m2ge n,
vi t er bi
demodmap
5-50
demodmap
Purpose Di gi tal demodul ati on demappi ng
Syntax demodmap( met hod) ;
demodmap( y, Fd, Fs , met hod) ;
demap_s i g = de modmap( y , Fd, Fs , met hod, . . . ) ;
[ x, t ] = de modmap( y, Fd, Fs , met hod, . . . ) ;
Description A di gi tal demodul ati on can be broken i nto two stages: anal og si gnal
demodul ati on and anal og to di gi tal si gnal demappi ng. The functi on demodmap
demaps an anal og si gnal to a di gi tal si gnal ; the r esul ti ng di gi tal si gnal i s the
cl osest poi nt to the i nput anal og si gnal . The demappi ng r esul t i s di fferent for
di fferent di gi tal modul ati on methods. You can speci fy the modul ati on method
usi ng the str i ng var i abl e met hod. The i nput vector si ze for demappi ng vari es for
di fferent methods.
Note that ' s ame ' , ' ey e' , and ' s c at t er ' are uti l i ti es that support
demodul ati on and not di gi tal demodul ati on schemes themsel ves.
demodmap( me t hod) pr ovi des mor e detai l ed hel p on a speci fi c demodul ati on
method.
Method Digital Modulation Scheme Input Size
' as k' M-ar y ampl i tude shi ft-keyi ng modul ati on no l i mi t
' f s k' M-ar y frequency shi ft-keyi ng modul ati on no l i mi t
' ms k' Mi ni mum shi ft-keyi ng modul ati on no l i mi t
' ps k' M-ar y phase shi ft-keyi ng modul ati on even col umn
' qas k' Quadr atur e ampl i tude shi ft-keyi ng
modul ati on
even col umn
' s ampl e ' A uti l i ty for resampl i ng Fd frequency si gnal
to Fs fr equency si gnal
no l i mi t
' ey e' Eye patter n di agr am pl ot no l i mi t
' s c at t e r ' Scatter pl ot no l i mi t
demodmap
5-51
de modmap( y, Fd, Fs , met hod) pl ots an eye-patter n di agram or scatter pl ot. Thi s
format can be used wi th method ' e ye ' or ' s c at t e r ' onl y.
de map_s i g = demodmap( y , Fd, Fs , met hod, . . . ) r ecover s the mapped di gi tal
si gnal usi ng the modul ati on method speci fi ed i n var i abl e me t hod. demap_s i g,
the output di gi tal si gnal to be r ecover ed, has frequency Fd. The si mul ati on
sampl e fr equency i s Fs (Her tz), and the i nput si gnal y has sampl i ng frequency
Fs . Fs /Fd must be a posi ti ve i nteger .
When i nput y i s a matri x, each col umn of y i s pr ocessed i ndependentl y, except
i n the cases wher e met hod equal s ' qas k' or ' ps k' . I n these cases, the i nput
matr i x si gnal i s processed two col umns at a ti me. The fi r st col umn i s the
i n-phase component of the i nput si gnal , and the second col umn i s the
quadrature component.The row number of the output matr i x demap_s i g i s:
Fd/Fs number _of _r ows _of _y
The ti me i nterval between two consecuti ve poi nts i n y i s 1/Fs , whi l e the ti me
i nter val between two consecuti ve poi nts i n de map_s i g i s 1/Fd.The ti me i nterval
between two consecuti ve poi nts i n x i s 1/Fs . The var i abl e Fs can be a scal ar or
a two-el ement vector . The fi rst el ement i s the sampl e frequency; the second
el ement, i f present, i s the i ni ti al phase i n the carr i er si gnal modul ati on. The
i ni ti al phase i s i n r adi ans, and i ts defaul t i s zero.
The ti me i nterval between two deci si on poi nts i s 1/Fd. The defaul t offset for the
deci si on poi nt i s 0. When Fd i s a two-el ement vector, the second el ement i n Fd
i s the deci si on ti mi ng offset. Thi s functi on measures the di stance of the
recei ved si gnal to al l possi bl e di gi ts i n the codi ng scheme. The di gi t cl osest to
the recei ved si gnal poi nt i s sel ected as the output di gi t.
A di gi tal demodul ati on i ncl udes two parts: anal og demodul ati on and anal og to
di gi tal demappi ng. Thi s functi on can hel p you obtai n the i ntermedi ate resul t.
You can break the command:
r ec _s i g = ddemod( y , Fc, Fd, Fs , met hod, . . . ) ;
i nto two commands:
z = dde mod( y , Fc, Fd, Fs , [ met hod, ' /nmap' ] , . . . ) ;
r ec _s i g = de modmap( z , Fd, Fs , met hod, . . . ) ;
I n thi s exampl e, the swi tch ' /nmap' i s appended to the method that di sabl es
the mappi ng pr ocess. The i ntermedi ate si gnal z has a sampl e fr equency Fs .
demodmap
5-52
Except the for mat of method equal s ' ey e' and ' s cat t er ' , the functi on can
al so pl ot an eye-pattern di agram when an amendment '/ey e' i s added to the
end of the vari abl e met hod. The functi on pl ots a scatter pl ot when an
amendment '/s c at t e r ' i s added to the end of the var i abl e method. The functi on
provi des onl y one pl ot i f both of '/e ye ' and '/s c at t er ' are speci fi ed. The opti on
'/s cat t er ' i s good for use wi th 'as k' and 'qas k' methods onl y.
method = 'ask'
r ec _s i g = demodmap( y , Fd, Fs , ' as k' , M) demaps an M-ary ASK mapped
si gnal . The M-ary number for the M-ar y ASK i s M. The output di gi tal si gnal i s
an i nteger i n the r ange [0, M1].
method = 'psk'
r ec _s i g = demodmap( y , Fd, Fs , ' ps k' , M) demaps an M-ary PSK modul ated
si gnal . The M-ary number for the M-ar y PSK i s M. The output di gi tal si gnal i s
an i nteger i n the r ange [0, M1].
method = 'qask'
Thi s functi on supports thr ee constel l ati ons: squar e, ci r cl e, and arbi trar y
constel l ati ons.
The square constel l ati on has a squar e shape, whi ch i s determi ned by the M-ary
number M. Usual l y, M=2
K
, wher e K i s a posi ti ve i nteger. The maxi mum i n-phase
and quadrature val ues i n the constel l ati on are:
M=2
K
In-phase Quadrature
2 1 1
4 1 1
8 3 1
16 3 3
32 5 5
64 7 7
128 11 11
256 15 15
demodmap
5-53
A ci r cl e constel l ati on i s defi ned by usi ng three equal l ength vector s. These
three vectors ar e:
noc (Number of symbol s on each ci rcl e),
r oc (Radi i on each ci rcl e), and
poc (Phase shi ft on each ci r cl e, i n r adi an).
The M-ary number of thi s bl ock equal s the summati on of al l el ements i n noc .
Let noc be [N
1
, N
2
,..., N
K
]; r oc be [R
1
, R
2
,..., R
N
]; and poc be [P
1
, P
2
,..., P
K
]. Then the
i th ci r cl e has N
i
el ements, i = 1, ..., N. The N
i
poi nts are evenl y di stri buted on
the i th ci rcl e wi th thei r radi i equal R
i
. One of the poi nts on the i th ci r cl e has
phase P
i
. I n another wor ds, the N
i
poi nts on the ci rcl e ar e l ocated at the
posi ti ons:
The el ements i n the vectors noc and r oc must be posi ti ve. For a corr ect
demappi ng, the el ements shoul d have no repeati ng poi nts.
You can defi ne an arbi trar y constel l ati on by usi ng two of same l ength vectors.
The two vector s are the i n-phase component, i n_phas e , and the quadrature
component, quad. The M-ar y number of the mappi ng equal s the l ength of the
vectors. The i n-phase val ue and the quadr atur e val ue of symbol i , i = 0,
1, . . . , M1, are defi ned i n the (i +1)th el ement i n the i n_phas e vector and i n
the quad vector r especti vel y.
r e c _s i g = demodmap( y , Fd, Fs , ' qas k' , M) demaps a squar e constel l ati on
QASK mapped si gnal . The M-ar y number for QASK i s M. The output di gi tal
si gnal i s i n the r ange [0, M1].
r e c _s i g = de modmap( y, Fd, Fs , ' qas k/ar b' , i n_phas e , quad) demaps a QASK
mapped si gnal usi ng a customer-defi ned arbi trary constel l ati on. The i n-phase
component and the quadr ature component ar e defi ned i n the var i abl es
i n_phas e and quad r especti vel y. The vector s l ength of i n_phas e and quad must
be the same, the l ength i s the M-ar y number for the QASK.
R
i
e
j P
i
R
i
e
j P
i
2
N
i
------ - +
,
_
... R
i
e
j P
i
2 N
i
1 ( )
N
i
---------------------------- +
,
_
demodmap
5-54
r ec _s i g = demodmap( y , Fd, Fs , ' qas k/ci r cl e' , noc , r oc, poc) demaps a
QASK mapped si gnal usi ng ci rcl e constel l ati on. The number on ci rcl e (noc ),
radi i on ci rcl e (r oc ) and the phase on ci rcl e (poc ) defi nes the QASK
constel l ati on. The vector l ength of noc, r oc, and poc must be the same.
method = 'fsk'
r ec _s i g = demodmap( y , Fd, Fs , ' f s k' , M, t one) demaps a FSK mapped si gnal
usi ng the coherent method. The M-ary number for QASK i s M. The tone space
between two successi ve fr equency i s defi ned i n t one.
method = 'msk'
r ec _s i g = demodmap( y , Fd, Fs , ' ms k' ) demaps a MSK mapped si gnal . The
el ements i n the output vector x are bi nary numbers. The tone space, i .e., the
frequency separati on between successi ve frequenci es, defaul ts to t one = Fd.
method = 'psk'
r ec _s i g = demodmap( y , Fd, Fs , ' ps k' , M) demaps a PSK mapped si gnal . The
M-ar y number i s defi ned i n M.
method = 'sample'
r ec _s i g = demodmap( y , Fd, Fs , ' s ampl e' ) conver ts sampl i ng rate Fs i nput
si gnal y to sampl i ng rate Fd output si gnal x , where Fs > Fd and Fs / Fd are
posi ti ve i ntegers.
method = 'eye'
demodmap( y, Fd, Fs , ' ey e' ) pl ots an eye-patter n di agram. The red ver ti cal l i ne
wi th a D poi nt mar k i ndi cates the deci si on poi nt l i ne by the gi ven sampl e
ti me.
method = 'scatter'
demodmap( y, Fd, Fs , ' s c at t e r ' ) produces a scatter pl ot from the i nput si gnal y.
See Also dmod, demod, dmodc e, ddemodce , modmap
dmod
5-55
dmod
Purpose Di gi tal modul ati on, passband si mul ati on
Syntax dmod( met hod) ;
dmod( met hod, . . . ) ;
y = dmod( x, Fc , Fd, Fs , met hod, . . . ) ;
[ y , t ] = dmod( x , Fc , Fd, Fs , met hod, . . . ) ;
Description Functi on dmod modul ates an i nput si gnal and i s desi gned for passband di gi tal
modul ati on si mul ati on. You can speci fy the modul ati on method usi ng the
str i ng vari abl e method. The tabl e bel ow l i sts the types of modul ati on avai l abl e:
Note that ' s ampl e' i s a uti l i ty that suppor ts modul ati on and not a modul ati on
scheme i tsel f.
dmod( met hod) provi des mor e detai l ed hel p on a speci fi c modul ati on method.
dmod( met hod, . . . ) pl ots a constel l ati on of si gnal poi nts for the type of
modul ati on sel ected.
y = dmod( x, Fc , Fd, Fs , met hod, . . . ) modul ates the di gi tal message si gnal x
wi th carr i er frequency Fc (Her tz) and si mul ati on sampl e fr equency Fs (Hertz).
The output si gnal y has sampl i ng frequency Fs , and the i nput si gnal x has
sampl i ng frequency Fd. Fs /Fd must be a posi ti ve i nteger.
When the i nput x i s a matri x, each col umn of x i s processed i ndependentl y. The
row number of the output matr i x y i s:
Fs /Fdr ow_number _of _x
Method Modulation Scheme
' as k' M-ar y ampl i tude shi ft-keyi ng modul ati on
' f s k' M-ar y frequency shi ft-keyi ng modul ati on
' ms k' Mi ni mum shi ft-keyi ng modul ati on
' ps k' M-ar y phase shi ft-keyi ng modul ati on
' qas k' Quadratur e ampl i tude shi ft-keyi ng modul ati on
' s ampl e ' Resampl i ng frequency si gnal Fd to frequency si gnal Fs
dmod
5-56
The ti me i nterval between two consecuti ve poi nts i n y i s 1/Fs whi l e the ti me
i nterval between two consecuti ve poi nts i n x i s 1/Fd. The var i abl e Fs can be a
scal ar or a two-el ement vector. The fi rst el ement i s the sampl e fr equency; the
second el ement, i f present, i s the i ni ti al phase i n the car ri er si gnal modul ati on.
The i ni ti al phase i s i n radi ans, and i ts defaul t val ue i s zer o. For best r esul ts,
Fs > Fc > Fd i s r ecommended.
[ y, t ] = dmod( . . . ) outputs the computati on ti me t . t i s a vector wi th i ts
l ength equal to the row number of y .
A di gi tal modul ati on i ncl udes two par ts: di gi tal to anal og mappi ng and anal og
modul ati on. To obtai n the i nter medi ate resul t, you can br eak the command:
y = dmod( x , Fc, Fd, Fs , met hod, . . . )
i nto two commands:
z = modmap( x , Fd, Fs , met hod, . . . ) ;
y = dmod( z , Fc, Fd, Fs , [ met hod, ' /nmap' ] , . . . ) ;
I n thi s exampl e, the swi tch ' /nmap' appended to met hod di sabl es the mappi ng
process. The i nter medi ate si gnal z has a sampl e frequency Fs .
method = 'ask'
dmod( ' as k' , M) pl ots the ASK constel l ati on.
y = dmod( x, Fc , Fd, Fs , ' as k' ) modul ates the i nput si gnal x usi ng the
ampl i tude shi ft-keyi ng method. Al l el ements i n x ar e non-negati ve i nteger s.
The i nput i nteger i s i n the r ange [ 0, M1] , and M = 2
K
such that max ( x ) <2
K
,
where K i s the mi ni mum i nteger that sati sfi es the i nequal i ty.
y = dmod( x, Fc , Fd, Fs , ' as k' , M) speci fi es the M-ar y number M.
method = 'fsk'
dmod( ' f s k' , M) pl ots the FSK constel l ati on.
y = dmod( x, Fc , Fd, Fs , ' f s k' ) modul ates the i nput si gnal x usi ng the
frequency shi ft-keyi ng method. Al l el ements i n x ar e non-negati ve i ntegers.
The range of the i nput i nteger s i s [ 0, M1] , M = 2
K
. K i s the mi ni mum i nteger
sati sfyi ng max( x) <2
K
. The tone space, i .e., the frequency separ ati on between
successi ve frequenci es, defaul ts to t one = 2Fd/M.
y = dmod( x , Fc, Fd, Fs , ' f s k' , M, t one ) speci fi es the i nput di gi tal si gnal range
M and the tone space t one.
dmod
5-57
method ='msk'
dmod( ' ms k' , M) pl ots the MSK constel l ati on.
y = dmod( x, Fc , Fd, Fs , ' ms k' ) modul ates the i nput si gnal x usi ng the
mi ni mum shi ft-keyi ng method. Al l el ements i n x must be bi nary numbers. The
tone space, i .e., the frequency separ ati on between successi ve fr equenci es,
defaul ts to t one = Fd.
method = 'psk'
dmod( ' ps k' , M) pl ots the PSK constel l ati on.
y = dmod( x, Fc , Fd, Fs , ' ps k' ) modul ates the i nput si gnal x usi ng the phase
shi ft-keyi ng method. Al l el ements i n x are non-negati ve i ntegers. The r ange of
the i nput i nteger s i s [ 0, M1] . M = 2
K
such that max( x) <2
K
,

where K i s the
mi ni mum i nteger that sati sfi es the i nequal i ty.
y = dmod( x, Fc , Fd, Fs , ' ps k' , M) speci fi es the i nput M-ar y number M.
method = 'qask'
Thi s functi on supports thr ee constel l ati ons: squar e, ci r cl e, and arbi trar y
constel l ati ons.
The square constel l ati on has a squar e shape, whi ch i s determi ned by the M-ary
number. Usual l y, the M-ar y number M=2
K
, wher e K i s a posi ti ve i nteger . The
maxi mum i n-phase and quadratur e val ues i n the constel l ati on are:
M=2
K
In-phase Quadrature
2 1 1
4 1 1
8 3 1
16 3 3
32 5 5
64 7 7
128 11 11
256 15 15
dmod
5-58
A ci r cl e constel l ati on i s defi ned by usi ng three equal l ength vector s. These
three vector s are:
noc (Number of symbol s on each ci r cl e),
r oc (Radi i on each ci rcl e), and
poc (Phase shi ft on each ci r cl e, i n r adi an).
The M-ary number of thi s bl ock equal s the summati on of al l el ements i n noc .
Let noc be [N
1
, N
2
,..., N
K
]; r oc be [R
1
, R
2
,..., R
N
]; and poc be [P
1
, P
2
,..., P
K
]. Then the
i th ci r cl e has N
i
el ements, i = 1, ..., N. The N
i
poi nts are evenl y di stri buted on
the i th ci rcl e wi th thei r radi i equal R
i
. One of the poi nts on the i th ci r cl e has
phase P
i
. I n another wor ds, the N
i
poi nts on the ci rcl e ar e l ocated at the
posi ti ons:
The el ements i n the vectors noc and r oc must be posi ti ve. For a cor rect
demappi ng, they shoul d have no repeati ng poi nts.
You can defi ne an arbi trar y constel l ati on by usi ng two of same l ength vectors.
The two vector s are the i n-phase component, i n_phas e , and the quadratur e
component, quad. The M-ar y number of the mappi ng equal s the l ength of the
vectors. The i n-phase val ue and the quadr atur e val ue of symbol i , i = 0,
1, . . . , M1, are defi ned i n the (i +1)th el ement i n the i n_phas e vector and i n
the quad vector respecti vel y.
dmod( ' qas k' , M) pl ots the squar e QASK constel l ati on.
dmod( ' qas k/ar b' , i n_phas e , quad) pl ots the user -defi ned ar bi tr ary QASK
constel l ati on.
dmod( ' qas k/ci r cl e' , noc , r oc, poc) pl ots the ci rcl e constel l ati on.
y = dmod( x, Fc , Fd, Fs , ' qas k' ) modul ates the i nput si gnal x usi ng the squar e
constel l ati on QASK method. Al l el ements i n x ar e non-negati ve i nteger s. The
range of the i nput i ntegers i s [ 0, M1] , M = 2
K
. K i s the mi ni mum i nteger
sati sfyi ng max( x) <2
K
, K i s the mi ni mum i nteger that sati sfi es the i nequal i ty.
y = dmod( x, Fc , Fd, Fs , ' qas k' , M) speci fi es the M-ary number of the square
constel l ati on QASK.
R
i
e
j P
i
R
i
e
j P
i
2
N
i
------ - +
,
_
... R
i
e
j P
i
2 N
i
1 ( )
N
i
---------------------------- +
,
_
dmod
5-59
y = dmod( x, Fc , Fd, Fs , ' qas k/ar b' , i n_phas e, quad) modul ates the i nput
si gnal x usi ng the ar bi tr ar y constel l ati on QASK method wi th the i n-phase
component and quadr atur e component val ue pr ovi ded i n the vari abl es
i n_phas e and quad.
y = dmod( x , Fd, Fs , ' qas k/c i r cl e' , noc , r oc, poc) modul ates the i nput si gnal
x usi ng the ci rcl e constel l ati on QASK method wi th the number of symbol s on
each ci rcl e, r adi i for each ci r cl e, and phase shi ft for each ci rcl e speci fi ed i n
var i abl es noc , r oc , and poc respecti vel y.
method = 'sample'
y = dmod( x , Fc , Fd, Fs , ' s ampl e' ) converts sampl i ng r ate Fd i nput si gnal x to
sampl i ng rate Fs output si gnal y , where Fs >Fd and Fs /Fd ar e posi ti ve i nteger s.
See Also amod, ade mod, ddemod, amodc e, ademodce , modmap, demodmap
dmodce
5-60
dmodce
Purpose Di gi tal modul ati on, baseband modul ati on wi th compl ex envel ope
Syntax dmodc e( met hod) ;
dmodc e( met hod, . . . ) ;
y = dmodc e( x, Fd, Fs , met hod, . . . ) ;
[ y, t ] = dmodce ( x, Fd, Fs , met hod, . . . ) ;
Description Functi on dmodc e modul ates an i nput di gi tal si gnal wi th compl ex envel ope and
i s desi gned for baseband di gi tal modul ati on si mul ati on. You can speci fy the
modul ati on method usi ng the str i ng vari abl e method. The tabl e bel ow l i sts the
types of modul ati on avai l abl e:
Except for ' s ampl e ' , the modul ated si gnal output fr om thi s functi on i s the
compl ex envel ope of the modul ated si gnal , meani ng that the outputs ar e
compl ex numbers. Note that ' s ampl e ' i s a uti l i ty that supports modul ati on
and not a modul ati on scheme i tsel f.
dmodc e( met hod) provi des mor e detai l ed hel p on a speci fi c modul ati on method.
dmodc e( met hod, . . . ) pl ots a constel l ati on of the gi ven method.
y = dmodce ( x , Fd, Fs , met hod, . . . ) modul ates the di gi tal message si gnal x. Ts
i s the sampl i ng frequency of output si gnal y, and Fd i s the sampl i ng fr equency
of the i nput si gnal x . Fs /Fd must be a posi ti ve i nteger. When the i nput x i s a
Method Modulation Scheme Output y type
' as k' Ampl i tude shi ft-keyi ng modul ati on compl ex
' f s k' Fr equency shi ft-keyi ng modul ati on compl ex
' ms k' Mi ni mum shi ft-keyi ng modul ati on compl ex
' ps k' Phase shi ft-keyi ng modul ati on compl ex
' qas k' Quadr ature ampl i tude shi ft-keyi ng
modul ati on
compl ex
' s ampl e ' Resampl i ng fr equency si gnal Fd to
fr equency si gnal Fs
r eal
dmodce
5-61
matr i x, each col umn of x i s pr ocessed i ndependentl y. The row number of the
output matri x y i s:
Fs /Fdr ow_number _of _x
The ti me i nterval between two consecuti ve poi nts i n y i s 1/Fs whi l e the ti me
i nter val between two consecuti ve poi nts i n x i s 1/Fd. The var i abl e Fs can be a
scal ar or a two-el ement vector. The fi rst el ement i s the sampl e frequency; the
second el ement, i f present, i s the i ni ti al phase i n the car ri er si gnal modul ati on.
The i ni ti al phase i s i n radi ans, and i ts defaul t val ue i s zer o.
[ y , t ] = dmodc e( . . . ) outputs the computati on ti me t . t i s a vector wi th i ts
l ength equal to the row number of y .
A di gi tal modul ati on i ncl udes two par ts: di gi tal to anal og mappi ng and anal og
modul ati on. To obtai n the i nter medi ate r esul t, you can br eak the command:
y = dmodc e( x , Fd, Fs , met hod, . . . )
i nto two commands:
z = modmap( x , Fd, Fs , met hod, . . . ) ;
y = dmodc e( z , Fd, Fs , [ met hod, ' /nmap' ] , . . . ) ;
I n thi s exampl e, the swi tch ' /nmap' appended to met hod di sabl es the mappi ng
process. The i nter medi ate si gnal z has a sampl e frequency Fs .
method = 'ask'
dmodc e( ' as k' , M) pl ots the M-ary ASK constel l ati on.
y = dmodce ( x , Fd, Fs , ' as k' ) modul ates the i nput si gnal x usi ng the ampl i tude
shi ft-keyi ng method. Al l el ements i n x are non-negati ve i ntegers. The i nput
i nteger i s i n the range [ 0, M1] , and M = 2
K
such that max( x ) <2
K
, where K i s
the mi ni mum i nteger that sati sfi es the i nequal i ty.
y = dmod( x, Fd, Fs , ' as k' , M) speci fi es the M-ary number M.
method = 'fsk'
dmodc e( ' f s k' , M, t one) pl ots the M-ary FSK constel l ati on.
y = dmodc e( x, Fd, Fs , ' f s k' ) modul ates the i nput si gnal x usi ng the frequency
shi ft-keyi ng method. Al l el ements i n x are non-negati ve i ntegers. The r ange of
the i nput i nteger s i s [ 0, M1] , M = 2
K
. K i s the mi ni mum i nteger sati sfyi ng
dmodce
5-62
max ( x ) <2
K
. The tone space, i .e., the frequency separati on between successi ve
frequenci es, defaul ts to t one = 2Fd / M.
y = dmodce ( x , Fd, Fs , ' f s k' , M, t one) speci fi es the i nput di gi tal si gnal range M
and the tone space t one.
method = 'msk'
dmodc e( ' ms k' , M) pl ots the MSK constel l ati on.
y = dmodc e( x, Fc, Fd, Fs , ' ms k' ) modul ates the i nput si gnal x usi ng the
mi ni mum shi ft-keyi ng method. Al l el ements i n x must be bi nary number s. The
tone space, i .e., the frequency separati on between successi ve fr equenci es,
defaul ts to t one = Fd.
method = 'psk'
dmodc e( ' ps k' , M) pl ots the PSK constel l ati on.
y = dmodc e( x, Fd, Fs , ' ps k' ) modul ates the i nput si gnal x usi ng the phase
shi ft-keyi ng method. Al l el ements i n x ar e non-negati ve i ntegers. The range of
the i nput i nteger s i s [ 0, M1] . M = 2
K
such that max( x ) <2
K,
wher e K i s the
mi ni mum i nteger that sati sfi es the i nequal i ty.
y = dmodc e( x, Fd, Fs , ' ps k' , M) speci fi es the i nput M-ary number M.
method = 'qask'
Thi s functi on supports thr ee constel l ati on defi ni ti ons: square, ci rcl e, and
ar bi tr ary constel l ati ons.
The square constel l ati on has a squar e shape, whi ch i s determi ned by the M-ary
number M. Usual l y, M=2
K
, wher e K i s a posi ti ve i nteger. The maxi mum i n-phase
and quadrature val ues i n the constel l ati on are:
M=2
K
In-phase Quadrature
2 1 1
4 1 1
8 3 1
16 3 3
32 5 5
dmodce
5-63
A ci r cl e constel l ati on i s defi ned by usi ng three equal l ength vector s. These
three vectors ar e:
noc (Number of symbol s on each ci rcl e),
r oc (Radi i on each ci rcl e), and
poc (Phase shi ft on each ci r cl e, i n r adi an).
The M-ary number of thi s bl ock equal s the summati on of al l el ements i n noc .
Let noc be [N
1
, N
2
,..., N
K
]; r oc be [R
1
, R
2
,..., R
N
]; and poc be [P
1
, P
2
,..., P
K
]. Then the
i th ci r cl e has N
i
el ements, i = 1, ..., N. The N
i
poi nts are evenl y di stri buted on
the i th ci rcl e wi th thei r radi i equal R
i
. One of the poi nts on the i th ci rcl e has
phase P
i
. I n another wor ds, the N
i
poi nts on the ci rcl e ar e l ocated at the
posi ti ons:
The el ements i n the vectors noc and r oc must be posi ti ve. For a corr ect
demappi ng, ther e shoul d have no repeati ng poi nts.
You can defi ne an arbi trar y constel l ati on by usi ng two of same l ength vectors.
The two vector s are the i n-phase component, i n_phas e , and the quadrature
component, quad. The M-ar y number of the mappi ng equal s the l ength of the
vectors. The i n-phase val ue and the quadr atur e val ue of symbol i , i = 0,
1, . . . , M1, are defi ned i n the (i +1)th el ement i n the i n_phas e vector and i n
the quad vector r especti vel y.
dmodc e( ' qas k' , M) pl ots the squar e QASK constel l ati on.
dmodc e( ' qas k/ar b' , i n_phas e , quad) pl ots the user -defi ned ar bi tr ary QASK
constel l ati on.
dmodc e( ' qas k/ci r cl e' , noc , r oc, poc) pl ots the ci rcl e constel l ati on.
64 7 7
128 11 11
256 15 15
M=2
K
In-phase Quadrature
R
i
e
j P
i
R
i
e
j P
i
2
N
i
------ - +
,
_
... R
i
e
j P
i
2 N
i
1 ( )
N
i
---------------------------- +
,
_
dmodce
5-64
y = dmodc e( x, Fd, Fs , ' qas k' ) modul ates the i nput si gnal x usi ng the squar e
constel l ati on QASK method. Al l el ements i n x ar e non-negati ve i nteger s. The
range of the i nput i ntegers i s [ 0, M1] , M = 2
K
. K i s the mi ni mum i nteger
sati sfyi ng max( x) <2
K,
wher e K i s the mi ni mum i nteger that sati sfi es the
i nequal i ty.
y = dmodc e( x, Fd, Fs , ' qas k' , M) speci fi es the M-ar y number of the squar e
constel l ati on QASK.
y = dmodc e( x, Fd, Fs , ' qas k/ar b' , i n_phas e, quad) modul ates the i nput si gnal
x usi ng the ar bi tr ar y constel l ati on QASK method wi th the i n-phase component
and quadratur e component val ue pr ovi ded i n the var i abl es i n_phas e and quad.
y = dmod( x , Fd, Fs , ' qas k/c i r cl e' , noc, r oc, poc) modul ates the i nput si gnal
x usi ng the ci rcl e constel l ati on QASK method wi th the number of symbol s on
each ci r cl e, r adi i for each ci r cl e, and phase shi ft for each ci r cl e speci fi ed i n
var i abl es noc , r oc , and poc r especti vel y.
method = 'sample'
y = dmodc e( x, Fd, Fs , ' s ampl e' ) converts sampl i ng r ate Fd i nput si gnal x to
sampl i ng rate Fs output si gnal y, where Fs /Fd i s a posi ti ve i nteger.
See Also amod, ade mod, dmod, dde mod, amodce , ade modc e, modmap, de modmap
dpcmdeco
5-65
dpcmdeco
Purpose Di fferenti al pul se code modul ati on decode computati on i n source codi ng
Syntax s i g = dpc mdec o( i ndx, code book, pr edi c t or ) ;
[ s i g, quant ] = dpcmde co( i ndx , c odebook, pr e di ct or ) ;
Description s i g = dpc mde co( i ndx, c odebook, pr edi ct or ) decodes a di ffer enti al pul se code
modul ati on encoded i ndex si gnal , i ndx. You must speci fy the predi ctor s i n
pr e di ct or and the pr edi cti ve-er ror quanti zati on codebook i n c ode book. To
obtai n a corr ectl y decoded r esul t, the par ameters must match the par ameters
used i n e nc ode.
[ s i g, quant ] = dpc mdec o( i ndx, code book, pr edi c t or ) outputs the quanti zed
predi cti ve error i n quant .
The i nput par ameters c odebook and pr e di ct or can be esti mated by usi ng
functi on dpc mopt .
I n gener al , the pr edi ctor i s an Mth order tr ansfer functi on has the for m
[0, t
1
, t
2
, ..., t
M
].
See Also dpc me nc o, dpc mopt , c ompand
dpcmenco
5-66
dpcmenco
Purpose Di ffer enti al pul se code modul ati on encode computati on i n sour ce codi ng
Syntax i ndx = dpcmenc o( s i g, code book, par t i t i on, pr e di ct or )
[ i ndx , quant ] = dpc me nc o( s i g, c odebook, par t i t i on, pr edi c t or )
Description i ndx = dpcmenc o( s i g, code book, par t i t i on, pr e di ct or ) outputs a
di fferenti al pul se code modul ati on encoded i ndex, i ndx. s i g i s the i nput si gnal ,
and pr e di ct or speci fi es the predi cti ve transfer functi on. The predi cti ve-err or
quanti zati on parameter s are gi ven i n par t i t i on and code book. I n gener al , an
Mth order tr ansfer functi on pr edi c t or has the for m of [0, t
1
, t
2
, ... t
M
].
[ i ndx , quant ] = dpc me nc o( s i g, c odebook, par t i t i on, pr edi c t or ) outputs
the quanti zed val ue i n quant .
The i nput par ameters c odebook, par t i t i on, and pr edi ct or can be esti mated
by usi ng dpc mopt .
When pr e di c t or i s an or der one transfer functi on, the dpcm i s si mpl i fi ed to be
a del ta-modul ati on.
See Also dpc mdec o, dpcmopt , c ompand, quant i z
dpcmopt
5-67
dpcmopt
Purpose Opti mal trai ni ng of di ffer enti al pul se code modul ati on parameter s by usi ng
tr ai ni ng data
Syntax pr e di ct or = dpc mopt ( t r ai ni ng_s e t , or d)
[ pr edi c t or , code book, par t i t i on] =
dpc mopt ( t r ai ni ng_s et , or d, i ni _code book)
Description pr e di ct or = dpc mopt ( t r ai ni ng_s e t , or d) esti mates the pr edi cti ve tr ansfer
functi on pr e di c t or of a gi ven or der or d and the tr ai ni ng set t r ai ni ng_s e t .
[ pr edi c t or , code book, par t i t i on] =
dpc mopt ( t r ai ni ng_s et , or d, i ni _code book) pr oduces the predi cti ve transfer
functi on pr e di c t or , and opti mi zed codebook and par t i t i on for the
predi cti ve-err or. The i nput var i abl e i ni _code book can be ei ther the i ni ti al
val ues of the c odebook vector or the si ze of the vector code book.
See Also dpc me nc o, dpc mde co, quant i z , l l oy ds
encode
5-68
encode
Purpose Er ror-contr ol encodi ng
Syntax c ode = encode ( ms g, N, K) ;
c ode= e nc ode( ms g, N, K, met hod, opt ) ;
[ code , added] = e nc ode( . . . ) ;
Description e nc ode generates a codeword fr om a message si gnal by addi ng par i ty check bi ts
to the message. There are si x major er ror-contr ol code methods i mpl emented
i n thi s tool box. These methods ar e: Hammi ng code, l i near bl ock code, cycl i c
code, BCH code, Reed-Sol omon code, and convol uti onal code. You can use
e nc ode for al l these error -control methods.
c ode= e nc ode( ms g, N, K) encodes a bi nary message ms g usi ng Hammi ng code
techni que. The number of i nfor mati on bi ts i s K, and the codewor d l ength i s N.
The format of ms g can be ei ther a vector or a K col umn matr i x. A Hammi ng code
has a codewor d l ength 2
M
1, where M i s an i nteger number greater than or
equal to 3. The number of i nformati on bi ts i s 2
M
N1. Hammi ng code i s a si ngl e
err or-cor recti on code.
c ode= de c ode( ms g, N, K, met hod, opt ) encodes the message si gnal ms g usi ng an
err or-control codi ng speci fi ed i n met hod. The number of i nfor mati on bi ts i s K,
and the codeword l ength i s N. opt i s an opti onal parameter used i n some of the
methods. The tabl e bel ow l i sts the types of er ror -contr ol code avai l abl e wi th the
associ ated var i abl e str i ng:
Method Encode Scheme
' hammi ng' Hammi ng code. opt can be used to speci fy the pr i mi ti ve
pol ynomi al . The functi on uses a defaul t pr i mi ti ve
pol ynomi al i f opt i s not speci fi ed.
' l i ne ar ' Li near bl ock code. opt must speci fy the pari ty-check
matri x.
' cy cl i c ' Cycl i c code. opt , whi ch must be speci fi ed, contai ns the
generator pol ynomi al . You can use functi on cy c l pol y to
choose an appr opr i ate cycl i c pol ynomi al .
encode
5-69
I n al l the methods, message si gnal i n ms g can be a bi nary vector or an L-col umn
matr i x. I n usi ng any method other than 'r s ', L=N, the codewor d l ength. I n the
' r s ' method, L=M, where N=2
M
1. Mmust be an i nteger gr eater than or equal to
3. code can be ei ther a bi nar y di gi t or an i nteger i n the r ange of [0, 2
L
1]. I n the
l atter case, you must append ' /de c i mal ' to the stri ng var i abl e met hod
speci fi cati on. For exampl e, 'bch' i s equi val ent to ' bc h/bi nar y ' , but ' bc h/
de c i mal ' means that the data i n code i s i n an i nteger for mat. Except for the
' r s ' method, ms g can onl y be a vector when usi ng deci mal method (i nstead of
a matri x).
For ' r s ' method, you can al so speci fy r s /power ' , whi ch tel l s the functi on that
the for mat for the i nput ms g i s i n the power format i n GF(2
M
). The data range
i n power format i s I nf and 0 to 2
M
2. (Note that the codeword l ength
N = 2
M
1). I n both the 'r s /dec i mal ' and 'r s /powe r ' cases, ms g can be a vector or
an K col umn matr i x, wher e K i s the number of i nformati on bi ts. I n the
'bi nar y ' case, code can be ei ther a vector or an Mcol umn matri x.
Method Encode Scheme
' bc h' Bi nary BCH code. opt i s used to speci fy BCH code
generator pol ynomi al . The functi on uses a defaul t
generator pol ynomi al i f opt i s not speci fi ed. Use
command bc hpol y to vi ew the val i d ( N, K) pai rs for
BCH code.
' r s ' Reed-Sol omon code. The codeword for RS code must
have l ength equal to 2
M
1, wher e Mi s an i nteger no l ess
than 3. The number of i nfor mati on bi ts K must be l ess
than N. The err or-corr ecti on capabi l i ty T=f l oor ( ( NK) /
2) . Set NK to an even number. opt shoul d contai n a l i st
al l el ements i n GF(2
M
). I f opt i s not speci fi ed, thi s
functi on computes al l the el ements of GF(2
M
) pr i or to
the encode cal cul ati on.
' conv ol ' Convol uti onal code. opt , whi ch must be speci fi ed, can be
a l i near, nonl i near, or octal for m of the tr ansfer functi on
matr i x of the convol uti onal code. Read the descri pti on
for ge n2abc d for defi ni ti ons of the di ffer ent transfer
functi on for ms.
encode
5-70
The codewor d output code contai ns the r ecovered message. The format of code
matches the for mat of ms g. When ms g i s an K-col umn matr i x, the output code i s
an N-col umn matri x.
[code , adde d] = e ncode ( . . . ) outputs the number of col umns that the
functi on added i n order to make the encodi ng an exact si ze for K l ength message
i nput.
See Also dec ode, bchpol y, bchdec o, r s pol y , r s de co, c yc l pol y , cy cl ge n, s i m2ge n,
v i t er bi
errlocp
5-71
er rl ocp
Purpose Fi nd the err or -l ocati on pol ynomi al for BCH and Reed-Sol omon decodi ng
Syntax [ s i gma, er r ] = e r r l oc p( s y ndr ome, t , t p, e r r ) ;
Description [ s i gma, er r ] = e r r l oc p( s y ndr ome, t , t p, e r r ) cal cul ates the err or-l ocati on
pol ynomi al s i gma from the vector s yndr ome , the err or -cor recti on capabi l i ty t ,
the compl ete l i st of GF(2
m
) el ements t p, and err or message i nfor mati on e r r .
t y pe_f l ag = 1, uses the normal method. t y pe _f l ag = 0 uses a si mpl i fi ed
method. The si mpl i fi ed method can be used for bi nar y code onl y.
Warning Thi s functi on has no er ror check. Pl ease make sure al l parameter s ar e assi gned
cor rectl y.
See Also bc hde co, r s de c ode
eyescat
5-72
eyescat
Purpose Eye-patter n di agr am and/or scatter pl ot
Syntax e ye s c at ( x , Fd, Fs ) ;
e ye s c at ( x , Fd, Fs , of f s et ) ;
e ye s c at ( x , Fd, Fs , of f s et , Dpoi nt ) ;
Description An eye-patter n pl ot i s a si mpl e and conveni ent tool to study the effects of
i nter-symbol i nterfer ence and other channel i mpai rments for di gi tal
tr ansmi ssi on. The recei ved si gnal i s pl otted agai nst ti me. When the x-axi s ti me
l i mi t i s reached, the si gnal goes back to the begi nni ng of the ti me poi nt. Thus,
the pl ots overl ay each other . Usual l y, the ti me r ange i s an i nteger mul ti pl e of
the di gi tal transmi ssi on i nter val . The tr ansmi tted di gi tal si gnal i s a sampl ed
data on the recei ved anal og si gnal . The sampl i ng poi nt i s named as deci si on
poi nt. I n the opti mal case, the deci si on poi nt i s at the wi dest eye openi ng
poi nt.
A scatter pl ot r ecor ds the si gnal val ue at a gi ven deci si on poi nt. I n the best
case, the deci si on poi nt shoul d be at the ti me when the eye i s the most open i n
the eye-patter n di agram. When the i nput si gnal x i s a two-col umn matr i x, the
scatter pl ot i s a two-di mensi onal pl ot wi th the x-axi s as the fi r st i nput vector
el ement and the y-axi s as the second i nput vector el ement. The
two-di mensi onal pl ot i s wi del y used i n the QAM appl i cati on. I f the i nput vector
i s not a two-col umn matr i x, the pl ot i s a one-di mensi onal pl ot.
For mor e i nformati on on eye-pattern and scatter pl ots, r efer to Chapter 3, the
Tutorial.
e ye s c at ( x , Fd, Fs ) pl ots the eye-patter n di agr am. The ti me scal e for the pl ot
i s fr om 0 to 1/Fd. Si gnal x has sampl e frequency Fs . I t i s r equi r ed that Fs > Fd
and Fs /Fd i s a posi ti ve i nteger .
e ye s c at ( x , Fd, Fs , of f s et ) pl ots an eye-pattern di agr am wi th the ti me on the
x-axi s shi ft of f s e t number of poi nts, whi ch i s equi val ent to of f s et /Fs l ength
of ti me. The of f s et must be a posi ti ve i nteger . The eye-pattern di agram pl ots
i n the ti me range from of f s et /Fd to of f s et /Fs +1/Fd.
e ye s c at ( x , Fd, Fs , of f s et , Dpoi nt ) pl ots an eye-patter n di agr am or a scatter
pl ot dependi ng on the contents i n the vari abl e Dpoi nt .
eyescat
5-73
When Dpoi nt i s a i nteger , the contents i n Dpoi nt speci fy the deci si on poi nt
shi ft fr om the zero poi nt; i n other words, the deci si on poi nt occurs at ti me equal
to Dpoi nt /Fs +i /Fd.
When Dpoi nt i s a str i ng, the contents i n Dpoi nt speci fi es the type of the
symbol s for the scatter pl ot. The stri ng can be one of the fol l owi ng: + o . - -.
When a i l l egal stri ng i s speci fi ed, the functi on uses the defaul t stri ng .. The
deci si on poi nt i s pr ovi ded i n of f s et i n thi s case.
See Also modmap, dmod, dmodce
flxor
5-74
fl xor
Purpose Fl oati ng poi nt number excl usi ve OR (XOR) computati on
Syntax z = f l x or ( x , y ) ;
Description z = f l xor ( x, y) outputs excl usi ve OR computati on between two i ntegers x and
y , or between el ements of two equal si ze matri ces. The matr i x si ze of x must be
the same as that of y.
See Also gf pl us , gf add
gen2abcd
5-75
gen2abcd
Purpose Conver t a convol uti onal code transfer functi on i nto state space [ A, B, C, D] for m
Syntax [ A, B, C, D] = gen2abcd( gen) ;
[ A, B, C, D] = gen2abcd( t r an_f unc, c ode_par am) ;
[ A, B, C, D, N, K, M] = ge n2abcd( . . . ) ;
Description The i nput tr ansfer functi on can be a nonl i near transfer functi on, a state space
l i near transfer functi on, an octal for m, or a bi nar y for m. You can gener ate
nonl i near transfer functi ons usi ng s i m2l ogi , state space transfer functi ons
usi ng s i m2t r an, and octal and bi nar y for ms usi ng oc t 2ge n.
[ A, B, C, D] = gen2abc d( ge n) converts the transfer functi on stor ed i n ge n i nto
[ A, B, C, D] for mat, where A, B, C, and D ar e matr i ces. When ge n i s a nonl i near
tr ansfer functi on as descr i bed i n functi on s i m2l ogi , the output A stor es the U
vector, and B stores the V vector. Vectors U and V vector ar e descri bed i n
functi on s i m2l ogi . When ge n i s a l i near transfer functi on as descri bed i n
functi on s i m2ge n, or an octal for m transfer functi on as descri bed i n functi on
oc t 2gen, the matr i ces [ A, B, C, D] contai n the bi nar y coeffi ci ents of thi s
di ffer ence equati on:
[ A, B, C, D] = ge n2abcd( t r an_f unc, c ode _par am) converts the bi nar y transfer
functi on t r an_f unc wi th code _par am=[N, K, M] i nto [ A, B, C, D] format. N i s the
output vector l ength, K i s the i nput vector l ength, and M i s the state vector
l ength.
[ A, B, C, D, N, K, M] = ge n2abcd( . . . ) outputs the l ength of the output, i nput
and state vector s. N i s the output vector l ength, K i s the i nput vector l ength, and
Mi s the state vector l ength.
Note that the conversi on fr om the octal for m to the state space [ A, B, C, D]
format conversi on i s not necessar i l y a mi ni mal state space real i zati on. You ar e
encouraged to use the si m2tran i nstead of si m2gen to construct a l i near
tr ansfer functi on.
See Also enc ode, dec ode , s i m2ge n, s i m2l ogi , s i m2t r an, oc t 2ge n
x k 1 + ( ) Ax k ( ) Bu k ( ) + =
y k ( ) Cx k ( ) Du k ( ) + =
gen2par
5-76
gen2par
Purpose Conver si on between gener ator matr i x and par i ty-check matri x for l i near bl ock
codi ng
Syntax h = gen2par ( g) ;
Description h = ge n2par ( g) gener ates a par i ty-check matri x h from a generator matr i x g.
You can al so use thi s functi on to convert a pari ty-check matri x i nto a generator
matr i x. Thi s functi on wor ks i n conjuncti on wi th the l i near bl ock codi ng
method.
I n gener al , a gener ator matri x i s a matri x where . The generator
matr i x i s i n the form wher e P i s the coeffi ci ent
matr i x wi th i ts el ements equal to 0 or 1, and an i denti ty matri x. The
par i ty-check matri x H i s an matr i x that has the form:
Examples Let G equal [1 1 1 1 1];
H = gen2par ( G)
H =
1 0 0 0 1
0 1 0 0 1
0 0 1 0 1
0 0 0 1 1
G = gen2par ( H)
G =
1 1 1 1 1
See Also e nc ode, dec ode
k n n k >
G P I
k k
= k n k ( )
I
k k
n k ( ) n
H
I
n k ( ) n k ( )
P
T
=
gfadd
5-77
gfadd
Purpose Cal cul ate the sum of two GF(p) pol ynomi al s or the sum of two GF(p
M
) el ements
Syntax c = gf add( a, b) ;
c = gf add( a, b, p) ;
c = gf add( a, b, p, l e n) ;
Description c = gf add( a, b) cal cul ates the sum of two GF(2) pol ynomi al s. You must
ar range the pol ynomi al s i n ascendi ng order, i .e, the i nput vector
repr esents the pol ynomi al :
I n the case of GF(2), al l el ements of a shoul d be ei ther 0 or 1.
c = gf add( a, b, p) adds two pol ynomi al s a and b i n GF(p) for a gi ven pri me
number p. p can al so be a matri x that l i sts al l the possi bl e el ements of GF(p
M
),
where p i s a pr i me number and M a posi ti ve i nteger greater than one. I n thi s
case the functi on takes the el ements i n a and b as powers of i n the
exponenti al representati on of GF(p
M
). The output, a col umn vector c, i s
c
=
a

+
b
i n GF(p
M
). You can generate a l i st of al l el ements i n GF(p
M
) by usi ng the
command:
p = gf t upl e ( [ 1 : p^m2] ' , m, q) ;
c = gf add( a, b, p, l e n) adds two GF(p) pol ynomi al s a and b. The resul ti ng
GF(p) pol ynomi al c has l ength equal to l en. When l en i s a negati ve number,
the l ength c defaul ts to degr e e( c) +1.
Examples The addi ti on between two GF(2) pol ynomi al s a=[ 1 0 1 1] and b=[ 1 1 0] i s
c = gf add( a, b)
c =
1 1 0 1
a a
1
a
2
a
3
... a
n 1
a
n
=
a X ( ) a
1
a
2
X a
3
X
2
..... a
n 1
X
n 2
a
n
X
n 1
+ + + + + =
gfadd
5-78
The addi ti on between two GF(2
4
) vector a = [ I nf 1 3 5] and b=[ 9 6 3 1] i s
p = gf t upl e( [ 1: 2^42] ' , 4) ;
c = gf add( a, b, p) ;
c =
9 11 I nf 2
See Also gf mul , gf di v , gf t upl e , gf pr i mck
gfconv
5-79
gfconv
Purpose Gal oi s fi el d pol ynomi al convol uti onal (mul ti pl i cati on)
Syntax c = gf c onv( a, b) ;
c = gf c onv( a, b, p) ;
Description c = gf c onv( a, b) mul ti pl i es two GF(2) pol ynomi al s a and b. The r esul ti ng
bi nary pol ynomi al c has degr ee of degr e e ( a) + de gr e e( b) .
c = gf add( a, b, p) mul ti pl i es two pol ynomi al s a and b over GF(p). p must be a
pri me number.
The pol ynomi al s a and b, must be i n ascendi ng order , i .e, the i nput vector
r epr esents the pol ynomi al :
a
i
must be a non-negati ve number l ess than p. The output pol ynomi al c i s al so
i n ascendi ng or der.
Examples The mul ti pl i cati on of two GF(2) pol ynomi al a = [1 1 1] and b = [1 1] i s
c = gf c onv( a, b)
c =
1 0 0 1
See Also gf add, gf mul , gf di v, gf de conv
a a
1
a
2
a
3
... a
n 1
a
n
=
a X ( ) a
1
a
2
X a
3
X
2
..... a
n 1
X
n 2
a
n
X
n 1
+ + + + + =
gfcosets
5-80
gfcosets
Purpose Produce cycl otomi c cosets mod(p
M
-1) for a pr i me number p
Syntax c s = gf cos e t s ( m) ;
c s = gf cos e t s ( m, p) ;
Description c s = gf cos e t s ( m) pr oduces cycl otomi c cosets mod(2
m
1) wi th p = 2.
c s = gf cos e t s ( m, p) pr oduces cycl otomi c cosets mod(2
m
1) wi th pr i me p.
Each r ow of the output matr i x c s i s a coset. The fi rst col umn i s cal l ed the coset
l eader; r efer to Li n & Costel l o for a di scussi on of thi s concept. Because the
l ength of the coset may vary, an NaN i s used to fi l l out the extr a space to make
al l rows of cs have equal l ength.
Examples Fi nd the cosets for GF(2
4
):
c s = gf cos et s ( 4)
c s =
See Also gf pr i mf d, gf r oot s , gf mi npol
0 NaN NaN NaN
1 2 4 8
3 6 12 9
5 10 NaN NaN
7 14 13 11
gfdeconv
5-81
gfdeconv
Purpose Gal oi s fi el d pol ynomi al di vi si on
Syntax [ q, r ] = gf dec onv ( b, a) ;
[ q, r ] = gf dec onv ( b, a, p) ;
Description [ q, r ] = gf dec onv ( b, a) di vi des b by a r esul ti ng i n the quoti ent q and the
remai nder r i n GF(2).
[ q, r ] = gf de conv ( b, a, p) di vi des b by a, the resul ts of whi ch are the quoti ent
q and the r emai nder r i n GF(p).
You must arr ange the pol ynomi al s a and b i n ascendi ng order. The i nput vector
r epresents the pol ynomi al
a
i
must be a non-negati ve number l ess than p.
Algorithm Thi s functi on uses the same al gor i thm as dec onv i n the Si gnal Processi ng
Tool box.
See Also gf c onv, gf add, gf mul , gf di v
a a
1
a
2
a
3
... a
n 1
a
n
=
a X ( ) a
1
a
2
X a
3
X
2
..... a
n 1
X
n 2
a
n
X
n 1
+ + + + + =
gfdiv
5-82
gfdi v
Purpose Gal oi s fi el d el ement-by-el ement di vi si on
Syntax q = gf di v ( b, a) ;
q = gf di v ( b, a) ;
Description q = gf di v ( b, a) di vi des b by a; the resul t i s the quoti ent q, whi ch i s an el ement
i n GF(2). A zero el ement i n a wi l l r esul t i n a NaN sol uti on.
q = gf di v( b, a, p) di vi des b by a. The resul t i s the quoti ent q i n GF(p), where
p i s a pri me number . p can al so be a a l i st of al l el ements i n GF(p
M
), wher e p i s
pri me and M i s an i nteger gr eater than one. I n thi s case, q i s the r esul t of the
di vi si on oper ati on i n GF(p
M
).
See Also gf add, gf mul , gf t upl e , gf pr i mck, dec onv
gffilter
5-83
gffi l ter
Purpose Di gi tal fi l ter i ng over GF(2)
Syntax y = gf f i l t e r ( b, a, x ) ;
y = gf f i l t e r ( b, a, x , p) ;
Description y = gf f i l t e r ( b, a, x ) fi l ters the data x wi th the fi l ter descri bed by vectors a
and b to cr eate the fi l ter ed data y i n GF(2).
y = gf f i l t e r ( b, a, x , p) fi l ter s the data x wi th the fi l ter descri bed by vectors
a and b to cr eate the fi l tered data y i n GF(p).
The fi l ter sol ves a di ffer ence equati on:
The pol ynomi al s a and b must be i n ascendi ng or der, i .e, the i nput vector
r epr esents the pol ynomi al
a
i
must be a non-negati ve number l ess than p.
y n ( ) b
nb
x n ( ) b
nb 1
x n 1 ( ) ... b
1
x n nb 1 ( ) a
na 1
y n 1 ( ) + + + + + =
a +
1
y n na 1 ( )
a a
1
a
2
a
3
... a
n 1
a
n
=
a X ( ) a
1
a
2
X a
3
X
2
..... a
n 1
X
n 2
a
n
X
n 1
+ + + + + =
gffilter
5-84
Examples The i mpul se response of fi l ter wi th b = [ 1 0 0 1 0 1 0 1] , a = [ 1 0 1 1] :
y = gf f i l t er ( b, a, [ 1, z e r os ( 1, 19) ] ) ;
s t e m( y) ;
axi s ( [ 0, 20, . 1 1. 1] )
Algorithm Thi s functi on uses an al gori thm si mi l ar to functi on f i l t er and appl i es to
fi l ter s over GF(2) onl y. You can use f i l t e r for fi l ters over GF(2) by usi ng the
format:
y = abs ( r e m( f i l t er ( b, a, x) , 2) ) ;
Thi s may pr oduce an err or i f a i s not stabl e i n the r egul ar di scr ete-ti me system
anal ysi s and the vector x i s too l ong, or for a hi gh order fi l ter . gf f i l t e r can
produce an accur ate r esul t i n al l cases.
See Also gf add, gf mul , gf di v, gf t upl e, gf pr i mck, f i l t e r
0 2 4 6 8 10 12 14 16 18 20
0
0.2
0.4
0.6
0.8
1
gflineq
5-85
gfl i neq
Purpose Sol ve the l i near equati on A x =b over the GF(2) fi el d
Syntax x = gf l i neq( A, b) ;
Description x = gf l i neq( A, b) sol ves the l i near equati on A x =b over GF(2).
Algorithm Thi s functi on uses a Gaussi an el i mi nati on method.
See Also gf add, gf di v, gf t upl e, gf pr i mck, c onv
gfminpol
5-86
gfmi npol
Purpose Fi nd the mi ni mal pol ynomi al of a gi ven el ement over the GF(2
m
) fi el d
Syntax pl = gf mi npol ( k, m) ;
Description pl = gf mi npol ( k, m) pr oduces a mi ni mal pol ynomi al of the gi ven el ements k
i n the fi el d GF(2
m
), wher e m i s a posi ti ve i nteger gr eater than or equal to one.
Each el ement i of k r epr esents , wher e i s a generator el ement i n the
GF(2
m
) fi el d.
GF(2
m
) i s a fi el d generated by the defaul t degree m pr i mi ti ve pol ynomi al , wher e
m i s a posi ti ve i nteger. You can vi ew the defaul t pol ynomi al by usi ng the
command:
gf pr i mdf ( m)
When m i s a bi nary vector i nstead of a posi ti ve number, m i s a pri mi ti ve pol yno-
mi al gener ated the fi el d GF(2
deg
), where de g i s the degree of pol ynomi al m(X).
The output pl i s a row vector that r epresents the mi ni mal pol ynomi al . When k
i s a vector, the output pl i s a matri x where the i th row repr esents the mi ni mal
pol ynomi al associ ated wi th el ement k( i ) .
Examples A l i st of mi ni mum pol ynomi al s of , wher e i = 1, ..,2
m
1. I n thi s case, we
assume m=4:
di s p( ' The de f aul t pr i mi t i ve pol ynomi al ' )
gf pr e t t y( gf pr i mdf ( 4) )
m = 4;
pl = gf mi npol ( [ 2: 2^m] ) ;
f or i = 1: l e ngt h( pl )
di s p( [ ' el ement al pha^' , num2s t r ( i 1) ] )
gf pr et t y( pl ( i , : ) )
e nd

i 1

i
gfminpol
5-87
The commands output a l i st of mi ni mum pol ynomi al s. Thi s tabl e l i sts the
el ements of GF(2
4
) i n exponenti al for m and thei r associ ated pol ynomi al s:
See Also gf add, gf di v, gf t upl e, gf pr i mdf
Element of GF(2
4
) Minimal polynomial
Defaul t pri mi ti ve pol ynomi al 1+X+X
4

1
1+X+X
4

2
1+X+X
4

3
1+X+X
2
+X
3
+X
4

4
1+X+X
4

5
1+X+X
2

6
1+X+X
2
+X
3
+X
4

7
1+X
3
+X
4

8
1+X+X
4

9
1+X+X
2
+X
3
+X
4

10
1+X+X
2

11
1+X
3
+X
4

12
1+X+X
2
+X
3
+X
4

13
1+X
3
+X
4

14
1+X
3
+X
4
gfmul
5-88
gfmul
Purpose GF(p) pol ynomi al mul ti pl i cati on and GF(p
M
) el ement mul ti pl i cati on
Syntax c = gf mul ( a, b) ;
c = gf mul ( a, b, p) ;
Description c = gf mul ( a, b) outputs the r esul t of mul ti pl yi ng pol ynomi al a wi th
pol ynomi al b i n GF(2). The resul ti ng bi nar y pol ynomi al c has degree equal to
degr ee(a) + degree(b).
c = gf mul ( a, b, p) mul ti pl i es two pol ynomi al s a and b over GF(p), wher e p i s a
pri me number. When p i s a matri x that contai ns al l el ements i n GF(p
M
), thi s
functi on assumes a and b are power s of i n the exponenti al repr esentati on of
GF(p
M
). The output c , a col umn vector , i s
c
=
a

b
i n GF(p
M
).
You can produce a l i st of al l el ements i n GF(p
M
) by usi ng the command:
p = gf t upl e( [ 1: p^M2] ' , M, p)
The pol ynomi al s a and b must be i n ascendi ng or der, i .e, the i nput vector
r epr esents the pol ynomi al
a
i
must be a non-negati ve number l ess than p. The output c i s al so i n ascendi ng
order.
See Also gf add, gf di v , gf t upl e , gf pr i mck, c onv
a a
1
a
2
a
3
... a
n 1
a
n
=
a X ( ) a
1
a
2
X a
3
X
2
..... a
n 1
X
n 2
a
n
X
n 1
+ + + + + =
gfplus
5-89
gfpl us
Purpose Add two el ements i n GF(q
M
)
Syntax K = gf pl us ( i , j , al pha, bet a) ;
Description The el ements i n GF(q
M
) are repr esented i n exponenti al for mat. That i s, al l
el ements ar e of the for m
i
, where i = I nf, 0, 1, ..., q
M
2. I n thi s tool box, an
el ement i s represented by i ts power i ndex, i .
k = gf pl us ( i , j , al pha, bet a) outputs the addi ti ve resul t of two el ements i n
GF(q
M
), or
k
=
i
+
j
. Vari abl e al pha i s a l ength q
M
vector contai ni ng i ntegers
that are el ements i n GF(q
M
). The vector al pha can be generated by usi ng the
functi on
al pha = gf t upl e( [ 1 : q^m2] ' , m, q) q. ^[ 0 : M1] ;
Al l el ements i n al pha ar e i nteger s. bet a i s the i ndex compl ement of al pha.
That i s, i f al pha has i ndex i , then be t a has i ndex q
M
-2-i . You can use the
command
bet a( al pha + 1) = 0 : q^M 1;
to obtai n the vari abl e be t a. For most uses of gf pl us , q = 2, whi ch r epresents
an operati on on GF(2
M
).
Var i abl es i and j can be matri ces, and they must have the same di mensi ons.
Thi s functi on i s used i n BCH and R-S decodi ng computati ons.
Example Thi s exampl e adds two GF(2
5
) matr i ces.
i = r andi nt ( 100, 10, 2^5) ; % Cr eat e a 100- by - 10 mat r i x i n GF( 2
5
)
j = r andi nt ( 100, 10, 2^5) ;
al pha = gf t upl e( [ 1 : 2^5 2] ' , 5) 2. ^[ 0 : M1] ;
bet a( al pha + 1) = 0 : 2^5 1;
k = gf pl us ( i , j , al pha, be t a) ; % Addi t i ve c omput at i on.
See Also gf pl us , gf s ub, gf mul , gf x or
gfpretty
5-90
gfpretty
Purpose Pretty pr i nt a GF(2) pol ynomi al
Syntax gf pr e t t y( a) ;
gf pr e t t y( a, s t ) ;
gf pr e t t y( a, s t , n) ;
Description gf pr e t t y( a) pr i nts a pol ynomi al repr esentati on over GF(2). The functi on uses
the defaul t vari abl e X. The pr i nted pol ynomi al i s i n ascendi ng order and the
term wi th coeffi ci ent of zero i s dr opped.
gf pr e t t y( a, s t ) uses the var i abl e pr ovi ded i n the str i ng vari abl e s t .
gf pr e t t y( a, s t , n) pr i nts the pol ynomi al usi ng l i ne wi dth n i nstead of 79.
Examples gf pr e t t y( r e m( 1: 10, 2) , ' Z' ) outputs the fol l owi ng representati on:
See Also gf add, gf mul , gf di v, gf t upl e, gf pr i mck
Z Z
3
Z
5
Z
7
Z
9
+ + + +
gfprimck
5-91
gfpri mck
Purpose Check whether a GF(p) pol ynomi al i s i rr educi bl e and pr i mi ti ve
Syntax ck = gf pr i mck( a) ;
ck = gf pr i mck( a, p) ;
Description ck = gf pr i mc k( a) checks the i rr educi bl e and pr i mi ti ve property of a, a GF(2)
pol ynomi al .
ck = gf pr i mck( a, p) checks the i r reduci bl e and pri mi ti ve pr oper ty of a, a GF(p)
pol ynomi al .
The pol ynomi al a must be i n ascendi ng order, i .e, the i nput vector
r epr esents the pol ynomi al
a
i
must be a non-negati ve number l ess than p.
The functi on outputs a fl ag ck that categori zes the i nput pol ynomi al :
ck = 1 when a i s not an i r reduci bl e pol ynomi al .
ck = 0 when a i s i rr educi bl e but not a pr i mi ti ve pol ynomi al .
ck = 1 when a i s a pr i mi ti ve pol ynomi al .
Examples a = [ 1 0 1 1 1] i s not a i r reduci bl e pol ynomi al i n GF(2)
c k = gf mul ( a)
c k =
1
b = [ 1 1 1 1 1] i s a i r reduci bl e but not a pri mi ti ve pol ynomi al i n GF(2)
c k = gf mul ( b)
c k =
0
c = [ 1 0 0 1 1] i s a pr i mi ti ve pol ynomi al i n GF(2)
c k = gf mul ( c )
c k =
1
a a
1
a
2
a
3
... a
n 1
a
n
=
a X ( ) a
1
a
2
X a
3
X
2
..... a
n 1
X
n 2
a
n
X
n 1
+ + + + + =
gfprimck
5-92
Algorithm The i rr educi bl e pr oper ty i s veri fi ed by the theor y of any i rr educi bl e m degr ee
pol ynomi al f(X) over GF(2) di vi des .
An i rr educi bl e m degr ee pol ynomi al f(X) over GF(2) i s defi ned to be pri mi ti ve i f
the smal l est pol ynomi al i s
See Also gf add, gf mul , gf di v, gf t upl e
1 X
2
m
1
+
1 X
n
+ n 2
m
1 + =
gfprimdf
5-93
gfpri mdf
Purpose Provi de defaul t pri mi ti ve pol ynomi al s
Syntax pol = gf pr i mdf ( m) ;
pol = gf pr i mdf ( m, p) ;
Description pol = gf pr i mdf ( m) outputs the defaul t pri mi ti ve pol ynomi al pol at the
speci fi ed GF(2
m
). The pol ynomi al i s i n ascendi ng or der .
pol = gf pr i mdf ( m, p) outputs the defaul t pri mi ti ve pol ynomi al pol over the
speci fi ed fi el d GF(p
m
). The pol ynomi al i s i n ascendi ng or der.
Examples Li st the GF(2
m
) pr i mi ti ve pol ynomi al s for m fr om degr ee 3 to degree 10.
f or i = 3 : 10
gf pr et t y ( gf pr i mdf ( i ) )
e nd
See Also gf pr i mf d, gf pr i mck
1 X X
3
+ +
1 X X
4
+ +
1 X
2
X
5
+ +
1 X X
6
+ +
1 X
3
X
7
+ +
1 X
2
X
3
X
4
X
8
+ + + +
1 X
4
X
9
+ +
1 X
3
X
10
+ +
gfprimfd
5-94
gfpri mfd
Purpose Fi nd GF(p
m
) pri mi ti ve pol ynomi al s
Syntax pol = gf pr i mf d( m) ;
pol = gf pr i mf d( m, opt ) ;
pol = gf pr i mf d( m, opt , p) ;
Description pol = gf pr i mf d( m) fi nds one pri mi ti ve pol ynomi al for a gi ven degr ee on
GF(2
m
). m i s a posi ti ve i nteger.
pol = gf pr i mf d( m, opt ) fi nds pr i mi ti ve pol ynomi al (s) on GF(2
m
) fol l owi ng the
i nstructi ons provi ded i n the var i abl e opt .
opt can be an i nteger that i ndi cates the number of ter ms of the pri mi ti ve
pol ynomi al , i .e., the nonzero coeffi ci ents i n the pol ynomi al p.
opt can al so be a stri ng. When opt = 'mi n', the functi on fi nds one pr i mi ti ve
pol ynomi al that has the mi ni mal ter m i n pol . When opt = ' max' , the functi on
fi nds one pri mi ti ve pol ynomi al that has the maxi mal term i n pol . When
opt = ' ex h' , the functi on searches to fi nd al l the pr i mi ti ve pol ynomi al s.
When the output i s more than one pol ynomi al , each r ow represents one
pri mi ti ve pol ynomi al .
Thi s functi on i s useful for determi ni ng the Hammi ng code generator matri x
and par i ty-check matr i x.
pol = gf pr i mf d( m, opt , p) fi nds pr i mi ti ve pol ynomi al s i n GF(p
m
) fol l owi ng the
i nstructi on as gi ven i n opt .
Thi s functi on outputs pol ynomi al s i n ascendi ng order form.
gfprimfd
5-95
Examples Fi nd and di spl ay al l pr i mi ti ve pol ynomi al s wi th degr ees equal to 6.
x = gf pr i mf d( 6, ' e xh' ) ; % Fi nd al l pr i mi t i v e pol ynomi al s .
f or i = 1 : s i z e ( x )
gf pr e t t y( x ( i , : ) ) % Di s pl ay al l pr i mi t i v e pol ynomi al s
% us i ng a pr e t t y f or m.
e nd
Fi nd and di spl ay al l three terms of pri mi ti ve pol ynomi al s wi th degree equal to 7.
x = gf pr i mf d( 7, 3) ; % Fi nd al l 3 t er ms pr i mi t i v e pol y nomi al s .
f or i = 1 : s i z e ( x )
gf pr e t t y( x ( i , : ) ) % Di s pl ay al l pr i mi t i ve pol y nomi al us i ng
% a pr et t y f or m.
e nd
Algorithm The functi on does a sear ch based on a test usi ng gf pr i mc k.
See Also gf add, gf mul , gf di v, gf pr i mck
1 X X
6
+ +
1 X X
3
X
4
X
6
+ + + +
1 X X
2
X
5
X
6
+ + + +
1 X
2
X
3
X
5
X
6
+ + + +
1 X X
4
X
5
X
6
+ + + +
1 X
5
X
6
+ +
1 X X
7
+ +
1 X
3
X
7
+ +
1 X
4
X
7
+ +
1 X
6
X
7
+ +
gfrank
5-96
gfr ank
Purpose Cal cul ate the r ank of a matri x i n GF(p)
Syntax r k = gf r ank( a) ;
r k = gf r ank( a, q) ;
Description r k = gf r ank( a) cal cul ates the r ank of matr i x a i n GF(2).
r k = gf r ank( a, q) cal cul ates the rank of matri x a i n GF(q), wher e q i s a pri me
number.
Thi s functi on uses an al gori thm si mi l ar to the Gaussi an el i mi nati on method.
See Also gf l i ne
gfrepcov
5-97
gfr epcov
Purpose Conver t between GF(2) pol ynomi al r epr esentati ons
Syntax p1 = gf r e pc ov ( p2)
Description Thi s functi on conver ts between two pol ynomi al representati ons of GF(2). A
GF(2) pol ynomi al P i s i n ascendi ng order wi th the form of
where i s ei ther zer o or one. The r epr esentati on can be ei ther
A l i st al l of the coeffi ci ents of P(X) (wi th i ts el ements bei ng ei ther 0 or 1),
Di sti nct posi ti ve i nteger s. A nonzero el ement i i ndi cates i n the above
pol ynomi al P(X).
To el i mi nate ambi gui ty, i n the second case, no el ement i n P can be zer o
except when P i s a scal ar .
p1 = gf r e pc ov ( p2) converts the second representati on i nto the fi r st one.
Examples Conver t GF(2) pol ynomi al fr om form 2 to for m 1.
p2 = [ 1 3 5] ;
p1 = gf r e pc ov( [ 1 3 5] )
p1 =
[ 1 0 1 0 1]
See Also gf add, gf mul , gf di v, gf t upl e
P X ( ) p
0
... p
n 1
X
n 1
p
n
X
n
+ + + =
p
i
p
i 1
1 X
2
X
4
+ +
gfroots
5-98
gfr oots
Purpose Fi nd the roots of a bi nary pol ynomi al i n GF(p
m
)
Syntax r t = gf r oot s ( f ) ;
r t = gf r oot s ( f , or d) ;
r t = gf r oot s ( f , or d, p) ;
[ r t , r t _t upl e] = gf r oot s ( . . . ) ;
[ r t , r t _t upl e, al pha] = gf r oot s ( . . . ) ;
Description r t = gf r oot s ( f ) fi nds al l roots r t for a bi nar y pol ynomi al f(X) i n the fi el d
GF(2
or d
), wher e or d i s the degree of the pol ynomi al f(X). The output r t i s a
col umn vector wi th i ts l ength l ess than or equal to the degr ee of f(X). r t = i
means that ther e i s a root of , wher e i s the el ement i n GF(2
or d
).
r t = gf r oot s ( f , or d) fi nds al l r oots r t for bi nar y pol ynomi al f(X) i n the fi el d
GF(2
or d
). GF(2
ord
) i s a fi el d generated by the degr ee or d pr i mi ti ve pol ynomi al .
or d i s a posi ti ve i nteger that shoul d be l arger or equal to the degree of f(X).
When or d i s a bi nary vector i nstead of a posi ti ve number, thi s functi on
assumes i t r epr esents a pr i mi ti ve pol ynomi al that gener ates the fi el d GF(2
deg
),
where deg i s the degree of or d( X) . de g shoul d be greater than the degree of f(X).
r t = gf r oot s ( f , or d, p) fi nds al l r oots r t for bi nary pol ynomi al f(X) on
GF(2
or d
).
[ r t , r t _t upl e] = gf r oot s ( . . . ) outputs the roots r t and the m- tupl e of r t .
Each row of r t _t upl e r epr esents the or d- tupl e representati on of r t .
[ r t , r t _t upl e, al pha] = gf r oot s ( . . . ) output the or d-tupl e of , where i =0,
1, ...2
or d
1.
r t = [ i , j , . . . k] means that the roots of f(X) are the el ements
i
,
j
, ...
k
i n
GF(2
or d
). The l i st of GF(p
ord
) can be found by usi ng
[ t p, i dx ] = gf t upl e ( [ 1 : p^or d2] , or d, p)
Limitation The functi on onl y outputs the di sti nct roots of the pol ynomi al f(X) i n the fi el d.
See Also gf pr i mdf , gf r e pc ov , hammgen

i 1

i
gfsub
5-99
gfsub
Purpose Subtract two pol ynomi al s or el ements i n GF(p) or GF(p
M
)
Syntax c = gf s ub( a, b) ;
c = gf s ub( a, b, p) ;
c = gf s ub( a, b, c , p, l e n) ;
Description c = gf s ub( a, b) i s the same as gf add, whi ch cal cul ates the sum of two GF(2)
pol ynomi al s. The pol ynomi al s are i n ascendi ng or der , i .e, the i nput vector
r epr esents the pol ynomi al
As defi ned i n GF(2), al l el ements i n a shoul d be ei ther 1 or 0.
c = gf s ub( a, b, p) subtr acts pol ynomi al s b fr om b i n GF(p) for a gi ven pr i me
p. When p i s a matr i x that l i sts al l el ements i n GF(p
M
), thi s functi on takes the
el ements i n a and b as powers of i n the exponenti al repr esentati on of GF(p
M
).
The output c, a col umn vector , i s
c
=
a

b
i n GF(p
M
).
You can gener ate a l i st of al l el ements i n GF(p
M
) by usi ng:
p = gf t upl e ( [ 1 : p^m2] ' , m, q)
c = gf s ub( a, b, p, l e n) subtr acts GF(p) pol ynomi al b fr om a. The r esul ti ng
GF(p) pol ynomi al c keeps the gi ven l ength l en. When l en i s a negati ve number,
the l ength c equal s degree(c) + 1.
See Also gf add, gf mul , gf di v, gf conv , gf dec onv
a a
1
a
2
a
3
... a
n 1
a
n
=
a X ( ) a
1
a
2
X a
3
X
2
..... a
n 1
X
n 2
a
n
X
n 1
+ + + + + =
gftrunc
5-100
gftru nc
Purpose Remove meani ngl ess terms fr om a pol ynomi al over GF(2)
Syntax c = gf t r unc ( a) ;
Description c = gf t r unc ( a) removes al l hi gh order ter ms that have zer o coeffi ci ents and
outputs a shor tened for m of the pol ynomi al . The pol ynomi al a must be i n
ascendi ng or der, i .e, the i nput vector a = [ a
1
a
2
a
3
. . . a
n- 1
a
n
] r epresents
the pol ynomi al :
where a
i
i s ei ther 0 or 1.
When are zeros and i s nonzer o, gf t r unc returns
See Also gf add, gf mul , gf di v, gf t upl e, gf pr i mck
a X ( ) a
1
a
2
X a
3
X
2
..... a
n 1
X
n 2
a
n
X
n 1
+ + + + + =
a
i 1 +
a
i 2 +
... a
n
, , , a
i
c a
1
a
2
... a
i 1
a
i
=
gftuple
5-101
gftupl e
Purpose Cal cul ate the m-tupl e expr essi on of a pol ynomi al over GF(p)
Syntax t p = gf t upl e( a, or d) ;
t p = gf t upl e( a, or d, p) ;
t p = gf t upl e( a, or d, p, pr i m_c k) ;
[ t p, i ndx] = gf t upl e( . . . ) ;
Description t p = gf t upl e( a, or d) converts GF(2) pol ynomi al a to the or d-tupl e
repr esentati on t p i n GF(2
or d
). A i s a matr i x wi th each row r epr esenti ng i n
ascendi ng or der pol ynomi al wi th A(i, :) = [a
1
, a
2
, ... a
n
] representi ng
When a i s a col umn vector or a scal ar , each el ement repr esents a power of i n
the exponenti al representati on of the fi ni te fi el d.
The pr i mi ti ve pol ynomi al can be found by usi ng the commands gf pr i mdf and
gf pr i mf d. When or d i s a bi nar y vector i nstead of a posi ti ve number , or d i s
consi dered to be a pr i mi ti ve pol ynomi al gener ati ng the fi el d GF(2
or d
), wher e
de g i s the degr ee of or d( X) .
t p = gf t upl e( a, or d, p) gener ates the m-tupl e repr esentati on i n GF(p).
t p = gf t upl e( a, or d, p, pr i m_c k) i s cal l ed onl y i f or d i s a pol ynomi al . Thi s
format checks whether or d i s a pri mi ti ve pol ynomi al before fur ther
computati on.
[ t p, i ndx] = gf t upl e( . . . ) outputs the i ndex for m of the tupl e i n i ndx.
Note: When a i s a vector, make certai n whether i t i s a r ow or col umn vector. A
row vector repr esents a pol ynomi al . A col umn vector denotes power s of i n
the exponenti al representati on.
I n the i ndex r epr esentati on, any negati ve number i s equi val ent to I nf.
A
i
X ( ) a
1
a
2
X a
3
X
2
..... a
n 1
X
n 2
a
n
X
n 1
+ + + + + =
gftuple
5-102
Example Thi s exampl e pri nts the four -tupl e representati on tabl e generated by the
pri mi ti ve pol ynomi al p(X) = 1 + X + X
4
:
f or i =1: 2^42
[ t p, i ndx ] = gf t upl e( i , [ 1 1 0 0 1] ) ;
s t = num2s t r ( i ndx) ;
i f i ==0,
di s p( ' I ndex numbe r | 4- Tupl e r e pr es ent at i on' ) ;
e nd;
di s p( [ s t , s et s t r ( ones ( 1, 12- l engt h( s t ) ) 32) , |
, mat 2s t r ( t p) )
e nd
Algorithm Thi s functi on uses recur si ve cal l backs i n deter mi ni ng the i ndex.
See Also gf add, gf mul , gf di v, gf pr i mck
gfweight
5-103
gfwei ght
Purpose Cal cul ate the Hammi ng wei ght of a bl ock code based on a gener ator matri x or
a pari ty check matr i x
Syntax wt = gf we i ght ( g) ;
wt = gf we i ght ( g, gh_f l ag) ;
Description The Hammi ng wei ght of a bl ock code i s defi ned as the mi ni mum Hammi ng
di stance between any two codewor ds. The Hammi ng di stance i s defi ned as the
number of el ements that di ffer between two codewords. For exampl e, [1 0 0]
and [1 0 1] have a Hammi ng di stance equal to 1.
wt = gf wei ght ( g) outputs the Hammi ng wei ght of the gi ven generator matri x g.
wt = gf wei ght ( g, gh_f l ag) outputs the Hammi ng wei ght based on the gi ven
gener ator matr i x, pari ty check matr i x, or generator pol ynomi al . When
gh_f l ag=' ge n' , g i s a gener ator matri x. When gh_f l ag=' par ' , g i s a
pari ty-check matri x. When gh_f l ag=n, where n i s a posi ti ve i nteger i n
speci fyi ng the or der of the gener ator pol ynomi al , g i s a gener ator pol ynomi al .
See Also Hammgen, bc hpol y
hammgen
5-104
hammgen
Purpose Produce a par i ty-check matr i x and a generator matri x for Hammi ng code
Syntax h = hammgen( m) ;
h = hammgen( m, p) ;
[ h, g] = hammge n( . . . ) ;
[ h, g, n, k] = hammge n( . . . ) ;
Description Hammi ng code i s a cl ass of perfect codes. Gi ven a posi ti ve i nteger m3, the
par ameters of the Hammi ng code ar e pr ovi ded i n thi s tabl e:.
h = hammgen( m) pr oduces m-by-n pari ty-check matri x of Hammi ng code
provi ded a gi ven posi ti ve i nteger m. The functi on gf pr i mf gener ates the GF(2)
pri mi ti ve pol ynomi al used i n pr oduci ng the Hammi ng code.
h = hammgen( m, p) pr oduces a pari ty-check matr i x of Hammi ng code provi ded
a gi ven posi ti ve i nteger m and an mth degr ee GF(2) pri mi ti ve pol ynomi al p. p i s
i n ascendi ng order so that repr esents,
[ h, g] = hammge n( . . . ) pr oduces the k-by-n generator matri x, g, for Hammi ng
code as wel l as the pari ty-check matri x, h.
[ h, g, n, k] = hammge n( . . . ) produces the par i ty-check matr i x, h, generator
matr i x, g, and the di mensi on i nfor mati on n and k.
Parameters Number
number of i nformati on bi ts n = 2
m
1
Code l ength k = 2
m
m 1
Par i ty-check l ength m = n k
Er ror-corr ecti ng capabi l i ty t =1 (mi ni mum di stance i s 3)
p p
1
p
2
... p
n 1
p
n
=
p X ( ) p
1
p
2
X ..... p
n 1
X
n 2
p
n
X
n 1
+ + + + =
hammgen
5-105
Examples You can easi l y pr oduce the par i ty-check matr i x and gener ator matri x for any m
gr eater than or equal to 3. For exampl e, the pari ty-check matri x, h and
gener ator matr i x for m=3 ar e:
[ h, g] = hammge n( 3)
h =
1 0 0 1 0 1 1
0 1 0 1 1 1 0
0 0 1 0 1 1 1
g =
1 1 0 1 0 0 0
0 1 1 0 1 0 0
1 1 1 0 0 1 0
1 0 1 0 0 0 1
Algorithm Unl i ke gf t upl e whi ch processes one m-tupl e at a ti me, hammgen gener ates the
enti r e sequence from 0 to 2
m
1. The computati on al gori thm uses al l previ ousl y
computed val ues to pr oduce the computati on r esul t.
See Also gf t upl e , gf r e pcov, gf pr i mck
hank2sys
5-106
han k2sys
Purpose Gener ate a di scr ete-ti me system model from a Hankel matr i x
Syntax [ num, de n] = hank2s ys ( hankel , i ni , t ol ) ;
[ num, de n, s v ] = hank2s y s ( . . . ) ;
[ a, b, c, d] = hank2s ys ( . . . ) ;
[ a, b, c, d, s v ] = hank2s y s ( . . . ) ;
Description [ num, de n] = hank2s ys ( hankel , i ni , t ol ) generates a si ngl e i nput/si ngl e
output system tr ansfer functi on from the Hankel matri x hanke l . The system
i mpul se response at ti me i ni i s based on the tol erance t ol . The i nput Hankel
matr i x must be a square matr i x.i ni and t ol ar e scal ar val ues. Parameter s i ni
and t ol can be omi tted, thei r defaul t val ues ar e zer o 0.01r especti vel y. When
t ol >1, c ei l ( t ol ) i s the or der of the output system. When tol <1, i t i s the
tol erance val ue used i n sel ecti ng the si ngul ar val ue to determi ne the or der of
the system.[ num, den] ar e vectors that represent the numer ator and
denomi nator of the system model tr ansfer functi on.
[ a, b, c, d] = hank2s ys ( . . . ) outputs the state-space repr esentati on of a l i near
system. [ a, b, c, d] ar e matr i ces.
[ a, b, c, d, s v ] = hank2s y s ( . . . ) i ncl udes a vector s v that contai ns the
si ngul ar val ues of the Hankel matri x.
Algorithm Thi s functi on uses si ngul ar val ue decomposi ti on.
See Also i mp2s ys
hilbaf
5-107
hi l baf
Purpose Desi gn an anal og Hi l bert fi l ter
Syntax hi l baf ;
hi l baf ( Fc ) ;
hi l baf ( Fc , Ts ) ;
hi l baf ( Fc , Ts , Tol ) ;
[ num, de n] = hi l baf ( . . . ) ;
[ num, de n, dl y] = hi l baf ( . . . ) ;
[ a, b, c, d] = hi l baf ( . . . ) ;
[ a, b, c, d, s v ] = hi l baf ( . . . ) ;
Description An i deal Hi l bert fi l ter i s a non causal fi l ter that has a tr ansfer functi on
H(s) = j sgn(s). I ts i mpul se response i s h(t) =1/ t/ . Thi s i mpl ementati on of
the Hi l bert fi l ter r equi r es the addi ti on of a ti me del ay, whi ch must be greater
than 0. Thi s functi on uses a si ngul ar val ue decomposi ti on method to desi gn the
fi l ter, and i t uses a resi due method to convert a di scr ete fi l ter to an anal og
fi l ter.
There i s a di sconti nui ty i n the i mpul se r esponse of the fi l ter. The output of the
anal og Hi l ber t fi l ter depends on the i nput si gnal fr equency, the computati on
ti me i nterval , and the ti me del ay. See the functi on hi l bana for a di scussi on of
the compensator desi gn for a Hi l bert fi l ter .
hi l baf desi gns a four th order anal og Hi l bert fi l ter for a 1Her tz i nput si gnal .
The computati on ti me i nter val defaul ts to 1/90 seconds and the del ay i s set to
7/180 seconds. Thi s command pl ots the fi l ter output for a 1 Hertz i nput si gnal .
hi l baf ( Fc ) desi gns a fourth or der anal og Hi l bert fi l ter for a Fc Her tz i nput
si gnal . The functi on sets the computati on ti me i nter val to 1/Fc /90 and the
del ay to 7/Fc/180 seconds. Thi s command pl ots the fi l ter output for a 1 Hertz
i nput si gnal .
hi l baf ( Fc , Ts ) desi gns an anal og Hi l ber t fi l ter for a Fc Her tz i nput si gnal . The
computati on ti me i nter val i s Ts and the del ay equal s
( c e i l ( 7/180/Fc/Ts ) + 0. 5) Ts . The functi on deter mi nes the order of the
fi l ter usi ng the cal cul ati on tol er ance t ol = 0.05. Thi s command pl ots the fi l ter
output for a 1 Her tz i nput si gnal .
hilbaf
5-108
hi l baf ( Fc , Ts , Tol ) uses a speci fi ed tol erance. When t ol i s i n the r ange (0, 1),
the order of the fi l ter i s deter mi ned by
[ num, de n] = hi l baf ( . . . ) outputs the numerator , num, and denomi nator, de n,
of the anal og Hi l bert fi l ter .
[ num, de n, dl y] = hi l baf ( . . . ) outputs the fi l ter ti me del ay, dl y.
[ a, b, c, d] = hi l baf ( . . . ) outputs the state-space r epr esentati on of the fi l ter.
[ a, b, c, d, s v ] = hi l baf ( . . . ) outputs the si ngul ar val ues generated i n the
computati on.
See Also hi l bi i r , hi l bana
tr uncated si ngul ar val ue
maxi mum si ngul ar val ue
-------------------------------------------------------------------- tol
hilbiir
5-109
hi l bi i r
Purpose Hi l bert tr ansfor m fi l ter desi gn
Syntax hi l bi i r ;
hi l bi i r ( s t ) ;
hi l bi i r ( s t , dl y) ;
hi l bi i r ( s t , dl y, t ol ) ;
[ num, de n] = hi l bi i r ( . . . ) ;
[ num, de n, s v ] = hi l bi i r ( . . . ) ;
[ a, b, c, d] =hi l bi i r ( . . . ) ;
[ a, b, c, d, s v ] = hi l bi i r ( . . . ) ;
Description Functi on hi l bi i r desi gns a Hi l bert tr ansform fi l ter. An i deal Hi l ber t
tr ansfor m fi l ter has the tr ansfer functi on as , wher e
and si gn(.) i s the si gn functi on. The i mpul se response of the Hi l ber t tr ansfor m
fi l ter i s . Si nce the Hi l ber t transform fi l ter i s a noncausal fi l ter, thi s
functi on i ntroduces a ti me del ay, dl y. A Hi l bert transform fi l ter wi th thi s del ay
has an i mpul se response .
hi l bi i r desi gns a fourth or der di gi tal Hi l ber t transform fi l ter wi th a one
second del ay. The sampl e ti me i s 2/7. I n thi s parti cul ar desi gn, the tol erance
i ndex i s 0.05. Thi s for mat produces a pl ot of the i mpul se r esponse of the fi l ter
and, for compari son, the i mpul se response of the i deal Hi l ber t transform fi l ter
wi th a one second del ay.
hi l bi i r ( s t ) desi gns a Hi l bert tr ansfor m fi l ter wi th a sampl e ti me of s t
seconds and a one second del ay. The defaul t val ue for t ol = 0.05, whi ch
determi nes the or der of the fi l ter. Thi s format produces a pl ot of the i mpul se
response of the fi l ter and, for compari son, the i mpul se r esponse of the i deal
Hi l bert tr ansfor m fi l ter wi th a one second del ay.
hi l bi i r ( s t , dl y) desi gns a Hi l ber tr ansfor m fi l ter wi th a sampl e ti me of s t
seconds and a ti me del ay of dl y . The defaul t val ue for t ol = 0.05, whi ch
determi nes the or der of the fi l ter. Thi s format produces a pl ot of the i mpul se
response of the fi l ter and a compar i son of the i deal Hi l bert transform fi l ter wi th
a dl y second del ay.
H s ( ) j s ( ) sgn = j 1 =
h t ( )
1
t
----- =
h t ( )
1
t dl y ( )
------------------------- - =
hilbiir
5-110
hi l bi i r ( s t , dl y , t ol ) desi gns a Hi l ber tr ansfor m fi l ter wi th a sampl e ti me of
s t seconds and a ti me del ay of dl y . When t ol < 1, the or der of the fi l ter i s
determi ned by
When t ol >1, the or der of the fi l ter i s t ol .Thi s for mat pr oduces a pl ot of the
i mpul se response of the fi l ter and a compari son of the i deal Hi l ber t tr ansfor m
fi l ter wi th dl y second del ay.
[ num, de n] = hi l bi i r ( . . . ) outputs the numerator and denomi nator of the I I R
fi l ter s tr ansfer functi on.
[ num, de n, s v ] = hi l bi i r ( . . . ) outputs the numerator and denomi nator of the
I I R fi l ter s transfer functi on and the si ngul ar val ues of the Hankel matr i x used
i n the computati on.
[ a, b, c, d] = hi l bi i r ( . . . ) outputs the di screte-ti me state-space model of the
desi gned Hi l ber t transform fi l ter. [ a, b, c , d] ar e matr i ces.
[ a, b, c, d, s v ] = hi l bi i r ( . . . ) outputs the di scr ete-ti me state-space model of
the desi gned Hi l ber t transform fi l ter and the si ngul ar -val ues of the Hankel
matr i x used i n the computati on.
Si nce the fi l ter desi gn i s an approxi mati on, to get an accurate r esul t dl y shoul d
be at l east a few ti mes l ar ger than s t . At the poi nt t = dl y , the i mpul se response
of the Hi l ber t transform fi l ter can be i nterpr eted as 0, I nf, or I nf. I n the
functi on, thi s poi nt i s set to be zero, i f the poi nt i s encounter ed. To get an
accurate r esul t, the poi nt shoul d be avoi d. A suggested r el ated between dl y and
s t i s r e m( dl y, s t ) = s t /2. For exampl e, when dl y i s fi xed, s t coul d be chosen
as 2dl y/N, wher e N i s an posi ti ve i nteger.
Algorithm hi l bi i r cal cul ates the i mpul se response of the i deal Hi l bert tr ansfor m fi l ter
response wi th del ay. The r esponse curve i s fi tted by usi ng the SVD method
i ntroduced i n S.Y.Kungs paper and refi ned i n W.Wangs paper.
Examples At the MATLAB pr ompt, type hi l bi i r or [ num, de n] =hi l bi i r for a defaul t
val ue exampl e.
truncated-si ngul ar-val ue
maxi mum-si ngul ar -val ue
---------------------------------------------------------------------- tol <
htruthtb
5-111
htruthtb
Purpose Gener ate a si ngl e err or-cor recti on l ogi c matri x
Syntax t r t = ht r ut ht b( g) ;
Description Thi s functi on gener ates a si ngl e err or-cor recti on l ogi c matr i x. I t i s based on the
Hammi ng code tr uth tabl e generator .
t r t = ht r ut ht b( g) outputs a truth tabl e for si ngl e er ror-cor recti on code,
especi al l y Hammi ng code. The i nput of thi s bl ock i s a N-by-K matri x, whi ch
i ndi cates the codeword l ength i s N and the number of i nformati on bi ts i s K. The
output of thi s functi on i s an N-by-N matr i x. The cor recti on vector i s
t r t ( s yndr ome, : ) , where s y ndr ome i s represented i n a deci mal for m.
You can cal cul ate the s yndr ome by typi ng:
s yndr ome = r ec ei ve d_ve c t or t r ans pos e _of _par i t y_chec k_mat r i x
See Also de c ode, hammge n
imp2sys
5-112
i mp2sys
Purpose Gener ate a di scr ete-ti me system from an i mpul se response sequence
Syntax [ num, de n] = i mp2s y s ( i mpul s e , t ol , or d) ;
[ num, de n, s v ] = i mp2s ys ( . . . ) ;
[ a, b, c, d] = i mp2s y s ( . . . ) ;
[ a, b, c, d, s v ] = i mp2s ys ( . . . ) ;
Description [ num, de n] = i mp2s y s ( i mpul s e , t ol , or d) generates a si ngl e i nput/si ngl e
output l i near system model from i ts i mpul se response sequence i mpul s e based
on the speci fi ed tol erance tol . When t ol >1, c ei l ( t ol ) i s the order of the
output system. When t ol <1, t ol i s the tol er ance val ue i n sel ecti ng the si ngul ar
val ue to determi ne the or der of the system. The defaul t val ue of t ol i s 0.01.
Thi s functi on constructs a Hankel matri x for use i n generati ng the
di screte-ti me real i zati on. The si ze of the Hankel matri x can be speci fi ed by
var i abl e or d; the defaul t si ze i s:
[ num, de n] contai ns the numerator and denomi nator of the system model
tr ansfer functi on.
[ a, b, c, d] = i mp2s ys ( . . . ) outputs the state-space r epr esentati on of a l i near
system. [ a, b, c, d] are matri ces.
[ a, b, c, d, s v ] = i mp2s ys ( . . . ) outputs a vector s v that contai ns the si ngul ar
val ue of the Hankel matri x.
Examples You can use thi s code to compar e the i mpul se r esponse of a gi ven model to the
output of the i mp2s ys :
[ a, b, c, d] = dr mode l ( 5, 1, 1) ;
i mp = di mpul s e ( a, b, c , d, 1, 100) ;
[ a1, b1, c1, d1] = i mp2s y s ( i mp, 5) ;
i mp1 = di mpul s e( a1, b1, c 1, d1, 1, 100) ;
pl ot ( [ i mp, i mp1] ) ;
The i mpul se response of the two systems shoul d match cl osel y i f the ori gi nal
system i s stabl e.
See Also hank2s y s
isprime
5-113
i spr i me
Purpose Veri fy whether a number i s pri me
Syntax i s p = i s pr i me ( x ) ;
Description i s p = i s pr i me ( x ) r etur ns 1 for the el ements of x whi ch are pr i mes, 0
other wi se.
Examples Fi nd al l pri me number s l ess than or equal to 100:
x = [ 1: 2: 100] ;
pr i me s _numbe r s = x ( f i nd( i s pr i me ( x ) ==1) )
pr i me _numbe r s =
See Also pr i me s
3 5 7 11 13 17 19 23 29 31 37 41
43 47 53 59 61 67 71 73 79 83 89 97
lloyds
5-114
l l oyds
Purpose The Ll oyd al gori thm for scal ar quanti zati on par ameter opti mi zati on usi ng
tr ai ni ng data
Syntax [ par t i t i on, codebook] = l l oy ds ( t r ai ni ng_s et , i ni _code book) ;
[ par t i t i on, codebook]
= l l oyds ( t r ai ni ng_s e t , i ni _c odebook, t ol ) ;
[ par t i t i on, codebook]
=l l oy ds ( t r ai ni ng_s et , i ni _code book, t ol , p_f l ag) ;
[ par t i t i on, codebook, di s t or t i on] = l l oy ds ( . . . ) ;
[ par t i t i on, codebook, di s t or t i on, r e l _di s t or ] = l l oy ds ( . . . ) ;
Description [ par t i t i on, codebook] = l l oy ds ( t r ai ni ng_s et , i ni _code book) opti mi zes
the scal ar quanti zati on parameter s par t i t i on and code book usi ng the vector
t r ai ni ng_s e t . i ni _code book i s the i ni ti al guess of the code book val ues. A
c odebook l ength shoul d be gr eater than or equal to 2. The output code book has
the same l ength as i ni _c odebook. The output par t i t i on has i ts vector l ength
equal to the vector l ength of c odebook mi nus 1. When i ni _c odebook i s a scal ar
i nteger, the functi on uses i t as the desi r ed c odebook si ze. The opti mi zati on
processi ng ends when the r el ati ve di stor ti on val ue i s l ess than 10
-7
[ par t i t i on, codebook] = l l oy ds ( t r ai ni ng_s et , i ni _code book, t ol ) uses
the user-speci fi ed tol erance for the opti mi zati on ter mi nati on cr i teri on.
[ par t i t i on, codebook] = l l oyds ( t r ai ni ng_s e t , i ni _c odebook, t ol , p_f l ag)
pl ots the ori gi nal si gnal , the opti mi zed par ti ti on, and codebook i n a fi gure.
[ par t i t i on, codebook, di s t or t i on] = l l oy ds ( . . . ) outputs the fi nal
di stor ti on val ue i n the opti mi zati on.
[ par t i t i on, codebook, di s t or t i on, r e l _di s t or ] = l l oy ds ( . . . ) outputs the
fi nal r el ati ve di stor ti on val ues i n termi nati ng the computati on.
t r ai ni ng_s e t shoul d be the typi cal data for the si gnal to be pr ocessed. The
output par t i t i on and c odebook from thi s functi on ar e opti mi zed for the
tr ai ni ng set onl y.
lloyds
5-115
Examples Trai n the quanti zati on c odebook and par t i t i on for a 3-bi t transfer channel for
a si nusoi dal tr ansmi ssi on.
x = s i n( [ 0: 1000] pi /500) ; % Gene r at e a c ompl e t e per i od of
s i nus oi dal s i gnal .
[ par t i t i on, c odebook] = l l oy ds ( x , 2^3)
par t i t i on =
0. 8118 0. 5502 0. 2727 0. 0039 0. 2781 0. 5516 0. 8118
c odebook =
0. 9361 0. 5876 0. 4127 0. 1327 0. 1405 0. 4157 0. 6876 0. 9361
See Also compand, dpcmopt , quant i z
modmap
5-116
modmap
Purpose Map a di gi tal si gnal to an anal og si gnal pri or to modul ati on
Syntax modmap( met hod) ;
modmap( met hod, . . . ) ;
y = modmap( x, Fd, Fs , met hod, . . . ) ;
Description A di gi tal modul ati on can be broken i nto two stages: di gi tal to anal og mappi ng
and anal og si gnal modul ati on. Functi on modmap maps a di gi tal si gnal to an
anal og si gnal , so that the anal og si gnal i s r eady for modul ati on. You can speci fy
the type of modul ati on you want to use by speci fyi ng the str i ng vari abl e
met hod. The output var i abl e, y , i s a si gnal ready for anal og modul ati on. The
si ze of vari abl e y vari es dependi ng on whi ch modul ati on method you choose.
The tabl e bel ow l i sts the types of modul ati on avai l abl e:
I n the tabl e,
m = r ow_number _of _xFs /Fd;
n = c ol umn_numbe r _of _x ;
Method Digital Modulation Scheme Output
Size
Modulation
Method
' as k' M-ar y ampl i tude shi ft-keyi ng
modul ati on
m-by-n ' am'
' f s k' M-ar y fr equency shi ft-keyi ng
modul ati on
m-by-n ' f m'
' ms k' Mi ni mum shi ft-keyi ng
modul ati on
m-by-n ' f m'
' ps k' M-ar y phase shi ft-keyi ng
modul ati on
m-by-2n ' qam'
' qas k' Quadratur e ampl i tude
shi ft-keyi ng modul ati on
m-by-2n ' qam'
' s ampl e
'
Sampl i ng Fd fr equency si gnal to
Fs fr equency si gnal
m-by-n open
modmap
5-117
where x i s a vector, r ow_numbe r _of _x equal s the vector l ength of x , and the
col umn_number _of _x equal s 1. I n the cases wher e the output si ze equal s
m-by-2n, the odd numbered col umns contai n the i n-phase component and the
even number ed col umns contai n the quadr ature component. You can modul ate
the output of thi s functi on by usi ng ei ther amod (wi th a met hod l i sted on the
ri ght hand col umn of the above tabl e) or dmod (wi th ' /nomap' appended to the
met hod str i ng). For exampl e:
x = r andi nt ( 100, 1, 4) ;
y = modmap( x , 1, 10, ' qas k' , 4) ;
z 1 = amod( y , 3, 10, ' qam' ) ;
z 2 = dmod( y , 3, 1, 10, ' qas k/nomap' , 4) ;
I n thi s exampl e z 1 i s exactl y the same as z 2. Both z 1 and z 2 equal z 3 as gi ven
by:
z 3 = dmod( x , 3, 1, 10, ' qas k' , 4) ;
modmap( met hod) pr ovi des mor e detai l ed hel p on a speci fi c modul ati on method.
The var i abl e met hod i s a str i ng chosen fr om the above met hod l i sti ng.
modmap( met hod, . . . ) pl ots a constel l ati on of the gi ven method wi th speci fi ed
parameter s.
y = modmap( x, Fd, Fs , met hod, . . . ) modul ates the di gi tal message si gnal x
wi th carr i er frequency Fc (Her tz) and si mul ati on sampl e fr equency Fs (Hertz).
The output si gnal y has sampl i ng frequency Fs , and the i nput si gnal x has
sampl i ng frequency Fd. Fs /Fd must be a posi ti ve i nteger. I nput x can be a
vector or a matri x. When i t i s a matri x, each col umn of x i s processed
i ndependentl y. The row number of the output matri x y i s:
Fs /Fdr ow_number _of _x
The ti me i nterval between two consecuti ve poi nts i n y i s 1/Fs whi l e the ti me
i nter val between two consecuti ve poi nts i n x i s 1/Fd. The var i abl e Fs can be
ei ther a scal ar or a two-el ement vector. The fi r st el ement i s the sampl e
frequency; the second el ement, i f pr esent, i s the i ni ti al phase i n the car ri er
si gnal modul ati on. The i ni ti al phase u i s i n r adi ans; the defaul t i ni ti al phase i s
zero.
method = 'ask'
modmap( ' as k' , M) pl ots the M-ary ASK constel l ati on.
modmap
5-118
y = modmap( x, Fd, Fs , ' as k' ) maps the i nput si gnal x usi ng the M-ary
ampl i tude shi ft-keyi ng method. Al l el ements i n x ar e non-negati ve i nteger s.
The i nput i nteger i s i n the r ange [ 0, M1] . M = 2
K
, where K i s the mi ni mum
i nteger that sati sfi es the i nequal i ty max( x) <2
K
.
y = modmap( x, Fd, Fs , ' as k' , M) speci fi es the M-ary number M.
method = 'fsk'
modmap( ' f s k' , M) pl ots the FSK constel l ati on.
y = modmap( x, Fd, Fs , ' f s k' ) maps the i nput si gnal x usi ng the fr equency
shi ft-keyi ng method. Al l el ements i n x ar e non-negati ve i ntegers. The range of
the i nput i nteger s i s [ 0, M1] , wher e M = 2
K
. K i s the mi ni mum i nteger
sati sfyi ng the i nequal i ty max ( x ) <2
K
. The tone space, i .e., the fr equency
separ ati on between successi ve fr equenci es, defaul ts to t one = 2Fd/M.
y = modmap( x , Fd, Fs , ' f s k' , M, t one) speci fi es the i nput di gi tal si gnal range M
and the tone space t one.
method = 'msk'
modmap( ' ms k' , M) pl ots the MSK constel l ati on.
y = modmap( x, Fd, Fs , ' ms k' ) maps the i nput si gnal x usi ng the mi ni mum
shi ft-keyi ng method. Al l el ements i n x must be bi nar y numbers. The tone space
defaul ts to t one = Fd.
method = 'psk'
modmap( ' ps k' , M) pl ots the M-ary PSK constel l ati on.
y = modmap( x, Fd, Fs , ' ps k' ) maps the i nput si gnal x usi ng the phase
shi ft-keyi ng method. Al l el ements i n x ar e non-negati ve i ntegers. The range of
the i nput i nteger s i s [ 0, M1] , wher e M = 2
K
. K i s the mi ni mum i nteger that
sati sfi es the i nequal i ty max ( x ) <2
K,
.
y = modmap( x, Fd, Fs , ' ps k' , M) speci fi es the i nput M-ary number M.
method = 'qask'
Thi s functi on supports thr ee constel l ati ons: squar e, ci r cl e, and arbi trar y
constel l ati ons.
modmap
5-119
The square constel l ati on has a squar e shape, whi ch i s deter mi ned by a M-ary
number M. Usual l y, M=2
K
, wher e K i s a posi ti ve i nteger. The maxi mum i n-phase
and quadrature val ues i n the constel l ati on and the output vari abl e y ar e:
A ci r cl e constel l ati on i s defi ned by usi ng three equal l ength vector s. These
three vectors ar e:
noc (Number of symbol s on each ci rcl e),
r oc (Radi i on each ci rcl e), and
poc (Phase shi ft on each ci r cl e, i n r adi an).
The M-ary number of thi s bl ock equal s the summati on of al l el ements i n noc .
Let noc be [N
1
, N
2
,..., N
K
]; r oc be [R
1
, R
2
,..., R
N
]; and poc be [P
1
, P
2
,..., P
K
]. Then the
i th ci r cl e has N
i
el ements, i = 1, ..., N. The N
i
poi nts are evenl y di stri buted on
the i th ci r cl e wi th thei r r adi i equal R
i
. One of the poi nts on the i th ci r cl e has
phase P
i
. I n another wor ds, the N
i
poi nts on the ci rcl e ar e l ocated at the
posi ti ons:
The el ements i n the vectors noc and r oc must be posi ti ve. For a corr ect
demappi ng, ther e shoul d be no r epeati ng poi nts.
M=2
K
In-phase Quadrature
2 1 1
4 1 1
8 3 1
16 3 3
32 5 5
64 7 7
128 11 11
256 15 15
R
i
e
j P
i
R
i
e
j P
i
2
N
i
------- +
,
_
... R
i
e
j P
i
2 N
i
1 ( )
N
i
---------------------------- +
,
_
modmap
5-120
You can defi ne an arbi trar y constel l ati on by usi ng two equal l ength vectors.
The two vector s speci fy the i n-phase component, i n_phas e , and the quadratur e
component, quad. The M-ar y number of the mappi ng equal s the l ength of the
vectors. The i n-phase val ue and the quadr atur e val ue of symbol i , i = 0,
1, . . . , M1, are defi ned i n the (i +1)th el ement i n the i n_phas e vector and i n
the quad vector respecti vel y.
modmap( ' qas k' , M) pl ots the squar e QASK constel l ati on.
modmap( ' qas k/ar b' , i n_phas e, quad) pl ots the user -defi ned ar bi tr ary QASK
constel l ati on.
modmap( ' qas k/c i r cl e' , noc , r oc, poc) pl ots the ci r cl e constel l ati on.
y = modmap( x, Fd, Fs , ' qas k' ) maps the i nput si gnal x usi ng the square
constel l ati on QASK method. Al l el ements i n x ar e non-negati ve i nteger s. The
range of the i nput i ntegers i s [ 0, M1] , M = 2
K
. K i s the mi ni mum i nteger
sati sfyi ng the i nequal i ty max ( x ) <2
K,.
y = modmap( x, Fd, Fs , ' qas k' , M) speci fi es the M-ar y number of the squar e
constel l ati on QASK.
y = modmap( x, Fd, Fs , ' qas k/ar b' , i n_phas e , quad) maps the i nput si gnal x
usi ng the ar bi tr ary constel l ati on QASK method wi th the i n-phase component
and quadratur e component val ues provi ded i n the vari abl e i n_phas e and quad.
y = modmap( x, Fd, Fs , ' qas k/ci r c l e ' , noc , r oc , poc ) maps the i nput si gnal x
usi ng the ci rcl e constel l ati on QASK method wi th the number of symbol s on
each ci r cl e, r adi i for each ci r cl e, and phase shi ft for each ci r cl e speci fi ed i n
var i abl es noc , r oc , and poc r especti vel y.
method = 'sample'
y = modmap( x, Fd, Fs , ' s ampl e' ) converts sampl i ng r ate Fd i nput si gnal x to
sampl i ng r ate Fs output si gnal y , where Fs >Fd and Fs /Fd i s a posi ti ve i nteger .
See Also amod, ade mod, dmod, dde mod, amodce , ade modc e, demodmap
oct2gen
5-121
oct2gen
Purpose Conver t between octal and bi nar y for ms of a convol uti onal code tr ansfer
functi on matri x
Syntax [ t r an_f unc, code _par am] = oc t 2ge n( ge n) ;
ge n = oct 2gen( t r an_f unc, code_par am) ;
Description Assume the convol uti onal code i s a ( N, K, M) code, whi ch means that the wor d
l ength i s N, number of i nfor mati on bi ts i s K, and the maxi mum degree among
al l tr ansfer functi ons i s M. We use a thr ee el ement vector code _par am to
repr esent the code par ameter, i .e., code_par am=[ N, K, M] .
The bi nar y transfer functi on matri x t r ans _f unc i s a K-by-N(M+1) bi nar y
matr i x. t r an_f unc can be wr i tten as the fol l owi ng form:
where i s a l ength M+1 bi nary row vector , whi ch i s the transfer functi on fr om
i th i nput to j th output. The row vector r epr esents an ascendi ng ordered
pol ynomi al . For exampl e the (2,1,4) convol uti onal code
can be r epr esented by the code _par am=[ 2, 1, 4] and
The octal form of the tr ansfer functi on matr i x ge n has the for m of
i n whi ch i s the i th i nput j th output octal form tr ansfer functi on. Note that
the bi nary form of the transfer functi on i s i n ascendi ng order , the octal for m i s
al so a conver si on of the bi nary vector al ong the ascendi ng di r ecti on. Taki ng the
tran_func
t
11
t
12
... t
1N
... ...
t
K1
t
K2
... t
KN
=
t
i j
t
i j
1 X
3
X
4
+ + 1 X X +
2
X
4
+ +
tr an_func
1 0 0 1 1 1 1 1 0 1
=
gen
g
11
g
12
... g
1N
... ...
g
K1
g
K2
... g
KN
=
g
i j
oct2gen
5-122
same exampl e as we have used above, the octal for m of the transfer functi on
gen i s:
[ t r an_f unc, c ode _par am] = oct 2gen( ge n) conver ts an octal form of the
tr ansfer functi on matr i x ge n i nto a bi nary form of the tr ansfer functi on
t r an_f unc . The functi on converts ge n i nto the convol uti onal code parameter
c ode_par am = [ N, K, M] and the convol uti onal code tr ansfer functi on
t r an_f unc .
gen = oc t 2ge n( t r an_f unc , c ode _par am) converts a bi nar y for m of the transfer
functi on matri x t r an_f unc and code _par am i nto a octal form of tr ansfer
functi on matri x gen.
Examples Take the exampl e of conver ti ng the octal for m of transfer functi on i n the
exampl e i n s i m2gen to bi nary form and tr ansfer i t back to the octal for m.
gen = s i m2ge n( ' f i g_10_9' ) ;
[ t r an_f unc , c ode_par am] = oc t 2ge n( gen)
t r an_f unc =
c ode_par am =
gen2 = oc t 2gen( t r an_f unc, code _par am)
gen2 =
See Also s i m2gen
gen
46 72
=
1 0 0 0 0 0 1 1 1
0 0 0 1 0 0 1 0 1
3 2 2
4 0 7
0 4 5
primes
5-123
pr i mes
Purpose Gener ate a l i st of pri me numbers
Syntax p = pr i me s ( n) ;
Description p = pr i me s ( n) generates a r ow vector p, whi ch contai ns the pri me numbers
l ess than or equal to n.
See Also i s pr i me
qaskdeco
5-124
qaskdeco
Purpose QASK square constel l ati on demappi ng computati on
Syntax ms g = qas kdec o( x , y , m) ;
ms g = qas kdec o( x , y , m, mi nmax ) ;
Description ms g = qas kdec o( x , y , m) demaps the message si gnal ms g fr om the i n-phase
component val ue speci fi ed i n x and quadratur e component val ue speci fi ed i n y .
The mul ti pl e val ue m must be a posi ti ve i nteger number that i s the power of 2.
The functi on uses the defaul t mi ni mum and maxi mum val ues of the i n-phase
component and quadr ature component, whi ch ar e provi ded i n the tabl e i n
functi on qas kenco.
ms g = qas kdec o( x , y , m, mi nmax ) speci fi es the i n-phase and quadr ature
component mi ni mum and maxi mum val ues i n vari abl e mi nmax. mi nmax i s a
2-by-2 matr i x
See Also qas ke nc o, de code , de modmap
mi nmax
i n_phase_mi n i n_phase_max
quadr ature_mi n quadrature_max
=
qaskenco
5-125
qasken co
Purpose QASK square constel l ati on mappi ng computati on
Syntax qas ke nc o( m)
qas ke nc o( ms g, m)
[ x , y] = qas ke nc o( m)
[ x , y] = qas ke nc o( ms g, m)
Description qas ke nc o( m) pl ots the squar e constel l ati on for QASK wi th gi ven M-ar y
numbers i n m. m must be power of 2.
qas ke nc o( ms g, m) pl ots the l ocati on of the di gi tal si gnal ms g wi th the M-ary
number gi ven i n m. The el ements i n ms g must be i nteger s i n the r ange [ 0, m1] .
[ x , y] = qas ke nc o( m) outputs the square constel l ati on poi nts for 0: m1. The
i n-phase val ues are pr ovi ded i n x and the quadr atur e poi nts ar e pr ovi ded i n y.
[ x , y] = qas ke nc o( ms g, m) maps the message si gnal ms g i nto i n-phase
component i n x and quadratur e component i n y . m i s the M-ar y number and the
el ements i n ms g must be i nteger s i n the range [ 0, m1] .
The output maxi mum numbers ar e:
See Also enc ode, modmap, qas kde c ode
M=2
K
In-phase Quadrature
2 1 1
4 1 1
8 3 1
16 3 3
32 5 5
64 7 7
128 11 11
256 15 15
quantiz
5-126
quanti z
Purpose Produce a quanti zati on i ndex and a quanti zed output val ue
Syntax i ndx = quant i z ( s i g, par t i t i on) ;
[ i ndx , quant ] = quant i z ( s i g, par t i t i on, c odebook) ;
[ i ndx , quant , di s t or ] = quant i z ( s i g, par t i t i on, codebook) ;
Description Thi s functi on per for ms quanti zati on usi ng the par ameter par t i t i on. The
vector par t i t i on must be a str i ctl y ascendi ng or dered r eal vector . Assumi ng
the vector l ength of par t i t i on i s N1, the val ue of i ndex i s one of the N i ntegers
i n the r ange [0, N1]. The output i ndex equal s:
0 i f the si gnal s i g i s l ess than or equal to par t i t i on( 1) ,
i i f the si gnal s i g i s l ar ger than par t i t i on( i ) but l ess than or equal to
par t i t i on( i +1) , and
N1 i f the si gnal s i g i s l ar ger than par t i t i on( N1) .
c odebook hol ds the val ues assi gned to each parti ti on i n the quanti zati on; the
val ue for i ndx =i 1 i s i n codebook( i ) . For a l ength N1 par t i t i on, the
c odebook l ength must be N.
i ndx = quant i z ( s i g, par t i t i on) pr oduces a quanti zed i ndex i ndx. i ndx has
the same l ength as the si gnal vector s i g.
[ i ndx , quant ] = quant i z ( s i g, par t i t i on, c odebook) pr oduces the quanti zed
val ue i n quant .
[ i ndx , quant , di s t or ] = quant i z ( s i g, par t i t i on, code book) outputs di s t or ,
the esti mated di stor ti on val ue of thi s quanti zati on data set.
Note: There i s no dedi cated functi on for the decode process for quant i z
because the decodi ng i s as si mpl e as:
quant = codebook( i ndx +1) ;
See Also l l oyds , dpc menco, dpc mdec o
randbit
5-127
randbi t
Purpose Randoml y add ones i nto a zero vector
Syntax out = r andbi t ( n, m) ;
out = r andbi t ( n, m, pr ob) ;
out = r andbi t ( n, m, pr ob, s ee d) ;
Description out = r andbi t ( n, m) gener ates an n-by-m zer o matr i x wi th a si ngl e 1 pl aced i n
random posi ti ons i n each row.
out = r andbi t ( n, m, pr ob) gener ates an n-by-m zero matr i x wi th ones pl aced
i nto random posi ti ons. The pr obabi l i ty of a si ngl e 1 i n a row i s speci fi ed i n the
fi rst el ement of the vector pr ob. The pr obabi l i ty of doubl e 1s i n a r ow i s
speci fi ed i n the second el ement of the vector pr ob, and so on. The vector l ength
of pr ob cannot be l arger than m, the col umn si ze of the zer o matr i x. The el ement
val ue i n pr ob must be i n the range [0, 1], s um( pr ob) must be l ess than or equal
to one.
out = r andbi t ( n, m, pr ob, s ee d) speci fi es the s ee d i n the random number
gener ati on.
See Also r and, r andi nt
randint
5-128
randi nt
Purpose Uni for ml y di str i buted random i nteger and matri x generator
Syntax out = r andi nt ( n) ;
out = r andi nt ( n, m) ;
out = r andi nt ( n, m, r ange) ;
out = r andi nt ( n, m, r ange, s ee d) ;
Description out = r andi nt ( n) generates an n-by-n uni forml y di str i buted random bi nar y
matr i x.
out = r andi nt ( n, m) generates an n-by-m uni for ml y di str i buted random bi nary
matr i x.
out = r andi nt ( n, m, r ange) gener ates an n-by-m uni for ml y di str i buted i nteger
matr i x wi th the mi ni mum and maxi mum number speci fi ed i n the l ength 2
vector r ange . When the i nput vari abl e r ange i s a posi ti ve i nteger, the r ange
i s automati cal l y set as [ 0, r ange1] .
out = r andi nt ( n, m, r ange , s ee d) generates r andom numbers usi ng the gi ven
s ee d.
Examples To generate an evenl y di str i buted 10-by-10 matri x wi th the el ements of the
matr i x i n the r ange from 0 to 7, you can use ei ther one of the fol l owi ng
commands.
out = r andi nt ( 10, 10, [ 0, 7] )
out = r andi nt ( 10, 10, 2^3)
See Also r and
rcosfir
5-129
rcosfi r
Purpose Rai sed cosi ne FI R fi l ter desi gn
Syntax r c os f i r ( R) ;
r c os f i r ( R, n_T, r at e , T) ;
r c os f i r ( R, n_T, r at e , T, c ol or ) ;
r c os f i r ( R, n_T, r at e , T, f i l t e r _t ype) ;
r c os f i r ( R, n_T, r at e , T, f i l t e r _t ype, col or )
b = r cos f i r ( . . . )
[ b, s ampl e _t i me] = r c os f i r ( . . . )
Description The ti me r esponse of the rai sed cosi ne fi l ter has the for m of
r c os f i r ( R) pr oduces ti me r esponse and frequency response pl ots of the r ai sed
cosi ne fi l ter at gi ven r ol l of f factor R wi th defaul t n_T val ue [3, 3], defaul t r ate
val ue 5, and defaul t T val ue 1.
r c os f i r ( R, n_T, r at e , T) produces the ti me and fr equency responses of the
rai sed cosi ne fi l ter at a gi ven r ol l of f factor R. R i s l i mi ted to the range of
. n_T i s a l ength two vector that i ndi cates the number of T wi ndows
before and after zer o. The defaul t val ue for n_T i s [3, 3]. The par ameter r at e
i s the sampl e poi nt i n each T, or , the sampl i ng r ate of the fi l ter i s T/r at e . The
defaul t val ue of r at e i s 5. The or der of the FI R fi l ter i s:
( n_T( 2) n_T( 1) ) r at e
T i s the dur ati on of the di gi tal bi t. The defaul t val ue of T i s 1.
r c os f i r ( R, n_T, r at e , T, c ol or ) pr oduces ti me and fr equency r esponses of the
rai sed cosi ne fi l ter and a curve pl ot wi th the speci fi ed c ol or . The choi ces for
col or ar e the same as those l i sted for the pl ot functi on.
h t ( ) c
t
T
----
,
_
Rt
T
----------
,
_
cos
1
4R
2
t
2
T
2
----------------
-------------------------- si n =
0 R 1
rcosfir
5-130
r cos f i r ( R, n_T, r at e , T, f i l t er _t ype) pr oduces ti me response and frequency
response pl ots of a squar e r oot r ai sed cosi ne fi l ter i f f i l t e r _t y pe == ' s qr t ' .
The i mpul se response of a squar e r oot r ai sed cosi ne fi l ter i s:
r cos f i r ( R, n_T, r at e , T, f i l t er _t ype, col or ) produces ti me and fr equency
responses wi th the cur ve col or speci fi ed i n the stri ng var i abl e col or .
b = r c os f i r ( . . . ) returns the r ai sed cosi ne FI R fi l ter . The si ze of vector b i s
( n_T( 2) n_T( 1) ) r at e + 1.
[ b, s ampl e _t i me ] = r c os f i r ( . . . ) returns the FI R fi l ter and i ts sampl e ti me.
Examples A si mpl e exampl e to compare the di ffer ence between di ffer ent r ol l of f factors
can be done by usi ng these commands:
r cos f i r ( 0) ;
s ubpl ot ( 211) ; hol d on;
s ubpl ot ( 212) ; hol d on;
r cos f i r ( . 5, [ ] , [ ] , [ ] , [ ] , ' r - ' ) ;
r cos f i r ( 1, [ ] , [ ] , [ ] , [ ] , ' g- ' ) ;
See Also r cos i i r
h t ( ) 4r
1 r + ( )
t
T
--- -
,
_
cos
1 r ( )
t
T
--- -
,
_
si n
4r
t
T
----
--------------------------------------- +
T 4r
t
T
----
,
_
2
1
,
_
------------------------------------------------------------------------------------- =
rcosflt
5-131
rcosfl t
Purpose Fi l ter the i nput si gnal usi ng r ai sed cosi ne fi l ter
Syntax y = r cos f l t ( x , Fd, Fs ) ;
y = r cos f l t ( x , Fd, Fs , t ype_f l ag) ;
y = r cos f l t ( x , Fd, Fs , ' f i l t e r ' , num) ;
y = r cos f l t ( x , Fd, Fs , ' f i l t e r ' , num, de n) ;
y = r cos f l t ( x , Fd, Fs , t ype_f l ag, del ay ) ;
y = r cos f l t ( x , Fd, Fs , t ype_f l ag, del ay , r ) ;
y = r cos f l t ( x , Fd, Fs , t ype_f l ag, del ay , r , t ol ) ;
[ y , t ] = r cos f l t ( . . . ) ;
Description Functi on r cos f l t passes an i nput si gnal thr ough a rai sed cosi ne fi l ter. You can
speci fy the rai sed cosi ne fi l ter by the numerator and denomi nator of the fi l ter s
tr ansfer functi on. The functi on desi gns a rai sed cosi ne fi l ter i f the one i s not
gi ven.
y = r cos f l t ( x , Fd, Fs ) fi l ter s the i nput si gnal x usi ng a rai sed cosi ne FI R
fi l ter. The sampl e frequency for the i nput di gi tal si gnal x i s Fd, and the sampl e
frequency for the output si gnal y i s Fs . Fs must be l ar ger than Fd, and Fs /Fd
must be an i nteger. The r ow number of y (or vector l ength of y) i s:
Fs /Fdr ow_number _of _x
The other defaul t val ues are:
Variable Name Description Default Value
r r ol l off factor 0.5
del ay fi l ter ti me del ay 3
t ype_f l ag fi l ter type 'fi t/normal '
rcosflt
5-132
y = r cos f l t ( x , Fd, Fs , t ype_f l ag) gi ves speci fi c computati on i nstr ucti ons i n
str i ng var i abl e t ype_f l ag. The tabl e bel ow l i sts the types of desi gns avai l abl e:
The i nstructi ons can be combi ned together by usi ng a ' /' to separate the
i ndi vi dual i nstr ucti ons. For exampl e, ' i i r /s qr t /wde l ay/Fs ' i s a val i d
t ype_f l ag stri ng. The speci fi ed i nstr ucti ons cannot be contradi ct each other .
For exampl e, ' f i r /i i r ' and ' nor mal /s qr t ' ar e not val i d i nstructi ons.
Speci fyi ng 'def aul t ' wi th any other combi nati ons resul ts i n the overr i de of al l
other i nstr ucti ons; i n thi s case, the functi on uses onl y the defaul t setti ngs i n
the fi l ter desi gn.
y = r cos f l t ( x , Fd, Fs , ' f i l t er ' , num) passes i nput si gnal x thr ough an FI R
fi l ter gi ven i n num.
Type_flag Meaning
' f i r ' Desi gn an FI R r ai sed cosi ne fi l ter before fi l ter i ng the i nput
si gnal .
' i i r ' Desi gn an I I R rai sed cosi ne fi l ter before fi l teri ng the i nput
si gnal .
' nor mal ' The desi gned fi l ter i s a nor mal rai sed cosi ne fi l ter.
' s qr t ' The desi gned fi l ter i s a square root rai sed cosi ne fi l ter.
' wdel ay ' Keep the ful l l ength of the fi l ter ed r esul t. I n thi s case, the
r ow number of y (or the vector l ength of y) equal s
( l e ngt h_of _x + del ay ) Fs /Fd.
' Fs ' The i nput vari abl e x has sampl e frequency Fs i nstead of the
defaul t Fd. I n thi s case, onl y el ement x ( i Fs /Fd + 1, : ) i s
used i n the cal cul ati on. Al l other el ements i n x are i gnor ed.
' f i l t er ' Speci fy the transfer functi on of the fi l ter. Pr ovi de the
numerator of the fi l ter for an FI R fi l ter; pr ovi de the
numerator and the denomi nator for an I I R fi l ter .
' de f aul t ' Use al l defaul t setti ngs, whi ch means desi gn a normal FI R
r ai sed cosi ne fi l ter, and cut off the extra l ength of the del ay.
I nput si gnal has fr equency Fd.
rcosflt
5-133
y = r cos f l t ( x , Fd, Fs , ' f i l t e r ' , num, de n) passes i nput si gnal x thr ough an
I I R fi l ter. The numerator and the denomi nator of the fi l ter i s gi ven i n num and
de n r especti vel y.
y = r cos f l t ( x , Fd, Fs , t ype_f l ag, del ay ) speci fi es the ti me del ay i n the
rai sed cosi ne fi l ter desi gn. The val ue i n del ay i s a posi ti ve i nteger. The actual
ti me del ay i s de l ay/Fd i n the fi l ter desi gn.
y = r cos f l t ( x , Fd, Fs , t ype_f l ag, del ay , r ) speci fi es the r ol l off factor r . I n
gener al , i t i s a real number i n r ange [0, 1].
y = r cos f l t ( x, Fd, Fs , t ype_f l ag, del ay, r , t ol ) speci fi es the tol erance i n the
I I R fi l ter desi gn.
[ y, t ] = r cos f l t ( . . . ) outputs the sampl i ng ti me poi nts for the output vector y.
See Also r c os f i r , r c os i i r , r c os i ne
rcosiir
5-134
rcosi i r
Purpose Rai sed cosi ne I I R fi l ter desi gn
Syntax r cos i i r ( R) ;
r cos i i r ( R, T_de l ay, r at e , T, t ol ) ;
r cos i i r ( R, T_de l ay, r at e , T, t ol , f i l t er _t y pe ) ;
r cos i i r ( R, T_de l ay, r at e , T, t ol , f i l t er _t y pe , c ol or ) ;
[ num, de n] = r c os i i r ( . . . ) ;
[ num, de n, s ampl e_t i me ] = r cos f i r ( . . . ) ;
Description r cos i i r ( R) produces ti me and fr equency r esponse pl ots of the rai sed cosi ne
I I R fi l ter. n_t has the defaul t val ue 3, r at e the defaul t val ue 5, T the defaul t
val ue 1, and t ol the defaul t val ue 0.01.
r cos f i r ( R, n_T, r at e , T, t ol ) pr oduces ti me and fr equency response pl ots of a
rai sed cosi ne I I R fi l ter. The parameter s of the fi l ter ar e the same as those
descr i bed i n the functi on r cos f i r . R i s the r ol l of f factor ; i ts val ue i s l i mi ted
to . n_T speci fi es how many ti mes of T del ay i t woul d be. n_T i s a
posi ti ve i nteger. The defaul t val ue of n_T i s 3. r at e i s a i nteger speci fyi ng the
sampl e pi nts i n each T. The defaul t val ue of T i s 1. t ol i s the tol er ance val ue
that deter mi nes the order of the I I R fi l ter . I f t ol <1, t ol i s the tol erance factor .
I f t ol >= 1, ce i l ( t ol ) i s the or der of the I I R fi l ter. The defaul t val ue of t ol i s
0.01.
r cos i i r ( R, n_T, r at e , T, t ol , f i l t er _t ype ) produces a squar e r oot rai sed
cosi ne fi l ter i f f i l t e r _t ype == ' s qr t ' .
r cos f i r ( r , n_T, r at e , T, t ol , f i l t er _t ype , c ol or ) produces ti me and
frequency r esponses wi th the curve col or speci fi ed i n the str i ng var i abl e c ol or .
[ num, de n] = r c os f i r ( . . . ) gener ates the transfer functi on of the rai sed
cosi ne FI R fi l ter . The si ze of vector b i s ( n_T( 2) - n_T( 1) ) r at e + 1.
[ num, de n, s ampl e_t i me ] = r cos f i r ( . . . ) r etur ns the tr ansfer functi on and
sampl e ti me of the FI R fi l ter .
0 R 1
rcosiir
5-135
Examples A si mpl e exampl e to compar e the di fference between di ffer ent del ay taps can
be done by usi ng these commands.
r cos i i r ( 0, 10) ;
s ubpl ot ( 211) ; hol d on;
s ubpl ot ( 212) ; hol d on;
c ol = [ ' r - ' ; ' g- ' ; ' b- ' ; ' m- ' ; ' c - ' ; ' w- ' ] ;
R = [ 8, 6, 4, 3, 2, 1] ;
f or i = R
r c os i i r ( . 0, i , [ ] , [ ] , [ ] , [ ] , c ol ( f i nd( R==i ) , : ) ) ;
e nd;
From thi s exampl e, you can see the frequency r esponse of the fi l ter
approxi mate to the i dea rai sed cosi ne fi l ter wi th i ncreased T-del ay val ue.
See Also r c os f i r
rcosine
5-136
rcosi ne
Purpose Desi gn a rai sed cosi ne fi l ter
Syntax num = r cos i ne ( Fd, Fs ) ;
[ num, de n] = r c os i ne( Fd, Fs , t ype_f l ag) ;
[ num, de n] = r c os i ne( Fd, Fs , t ype_f l ag, de l ay) ;
[ num, de n] = r c os i ne( Fd, Fs , t ype_f l ag, de l ay, r ) ;
[ num, de n] = r c os i ne( Fd, Fs , t ype_f l ag, de l ay, r , t ol ) ;
Description num = r cos i ne ( Fd, Fs ) desi gns a fi ni te i mpul se r esponse (FI R) rai sed cosi ne
fi l ter . The i nput di gi tal si gnal has frequency Fd. The sampl i ng fr equency for
the fi l ter i s Fs . Fs must be l ar ger than Fd and Fs /Fd must be an i nteger . The
defaul t rol l off factor i s .5; and the ti me de l ay i s 3, whi ch means the fi l ter del ays
3/Fd second.
[ num, de n] = r c os i ne( Fd, Fs , t ype_f l ag) desi gns a rai sed cosi ne fi l ter usi ng
a method speci fi ed i n the str i ng vari abl e t ype_f l ag. Ther e ar e three possi bl e
opti ons for t ype_f l ag:
' i i r ' , whi ch di r ects the functi on to gener ate an i nfi ni te i mpul se response
(I I R) fi l ter .
' s qr t ' , whi ch di r ects the functi on to generate a squar e r oot rai sed cosi ne fi l -
ter.
' def aul t ' , whi ch di r ects the functi on to generate an FI R, nor mal rai sed co-
si ne fi l ter . The defaul t tol er ance val ue i n I I R fi l ter desi gn i s 0.01.
You can cr eate sui tabl e combi nati ons of desi gn methods; ' s qr t ' wi th the ' i i r '
or ' f i r ' : ' i i r /s qr t ' , but combi nati ons l i ke ' i i r /f i r ' ar e not al l owed.
[num, den] = r cos i ne ( Fd, Fs , t ype_f l ag, del ay ) provi des the ti me del ay step.
The val ue i n del ay i s a posi ti ve i nteger . The actual ti me del ay i s
del ay /Fd i n the fi l ter desi gn.
[ num, de n] = r cos i ne( Fd, Fs , t ype_f l ag, de l ay, r ) speci fi es the rol l off factor.
I n gener al , i t i s a real number i n the r ange [0, 1].
[ num, de n] = r cos i ne( Fd, Fs , t ype_f l ag, del ay , r , t ol ) speci fi es the tol erance
i n the I I R fi l ter desi gn.
See Also r cos f i r , r c os i i r , r c os f l t
rscore
5-137
rscore
Purpose The core of the Reed-Sol omon decode cal cul ati on
Syntax ms g = r s c or e( code, k, t p, di m, pow_di m) ;
[ ms g, er r , cc ode] = r s code ( c ode , k, t p, di m, pow_di m) ;
Description ms g = r s cor e ( c ode , k, t p, di m, pow_di m) decodes a si ngl e r ow of codewor ds i n
code vector usi ng the Reed-Sol omon decodi ng techni que. The number of
i nfor mati on bi ts i s k. The compl ete l i st of al l members i n GF(2
di m
) i s i n t p. di m
i s a posi ti ve i nteger. The codeword l ength i s provi ded i n pow_di m, whi ch equal s
2
di m
1.
[ ms g, er r , cc ode] = r s cor e ( c ode , k, t p, di m, pow_di m) outputs the message
si gnal ms g, the err or detected i n the decodi ng e r r , and the cor rected codeword
code.
Note that unl i ke the other encode/decode functi ons, thi s functi on takes an
exponenti al i nput i n the pr ocessi ng. For exampl e repr esents
i n GF(2
di m
). There are 2
m
el ements i n GF(2
m
). Hence, the i nput
code represents 2
m
(2
m
1) bi ts of i nfor mati on. The decoded ms g represents
2
m
k bi ts of i nformati on.
See Also de c ode, e nc ode , r s de code, r s dec o
I nf 0 1 2 ...
0 1
2
...
rsdeco
5-138
rsdeco
Purpose Reed-Sol omon decode computati on wi th a choi ce of di fferent for mats
Syntax ms g = r s dec o( c ode, n, k) ;
ms g = r s dec o( c ode, n, k, t ype_f l ag) ;
[ ms g, er r ] = r s de co( . . . ) ;
[ ms g, er r , cc ode ] = r s de co( . . . ) ;
[ ms g, er r , cc ode , c er r ] = r s de co( . . . ) ;
Description ms g = r s dec o( c ode, n, k) decodes the bi nar y message i n ms g usi ng the
Reed-Sol omon decodi ng techni que. The codeword l ength i s n, and the number
of i nfor mati on bi ts k; these val ues must agr ee wi th those used i n r s e nc o to
encode the ori gi nal message. A val i d Reed-Sol omon code shoul d have i ts
codewor d l ength n = 2
m
1, wher e m i s an i nteger greater than or equal to 3, and
must have i ts number of i nformati on bi ts k<n. The i nput var i abl e code must
have the same format as the output of r s e nc o. There are two possi bl e i nput
formats for c ode:
A col umn vector wi th l ength L or
An L-by-m matr i x.
I n the col umn vector for mat, the output ms g i s an Lc1 col umn vector where
Lc1 = Lk/n. I n the matr i x for mat, the output ms g i s a Lc 2-by-m matri x where
Lc2 = Lk/n. I n ei ther case, i f Lc1 or Lc2 i s not an i nteger , the functi on wi l l
gi ve er ror message and stop the decodi ng cal cul ati on. For faster cal cul ati on,
the codewor d l ength n can be the l i st of al l el ements i n GF(2
m
), a 2
m
-by-m
matr i x. You can generate thi s l i st usi ng gf t upl e .
ms g = r s dec o( c ode, n, k, t ype_f l ag) speci fi es the format of code by usi ng
t ype_f l ag. Ther e ar e three opti ons for t ype_f l ag:
' bi nar y' speci fi es the bi nary r epr esentati on for el ements i n code .
'deci mal ' speci fi es that the el ements i n code ar e base 10 i nteger s i n the range
[0 , n1].
' power ' speci fi es that the el ements of c ode ar e i n the power format for
GF(2
m
). See the Tutorial for a di scussi on of the power for mat for Gal oi s
fi el ds. The el ements i n thi s r epr esentati on are I nf and the i ntegers 0 to n1.
Any negati ve number i n thi s for m i s equi val ent to I nf.
rsdeco
5-139
I n ei ther the ' de c i mal ' or ' power ' case, the el ements i n c ode must match the
code type. I n both these cases, c ode can be ei ther:
A l ength L col umn vector, i n whi ch case the output ms g i s an Lc col umn vec-
tor wi th Lc = Lk/n.
An L-by-n matr i x (note the di mensi ons ar e di fferent fr om the ' bi nar y ' case,
i n whi ch case the output c ode i s a L-by-k matri x.
[ ms g, er r ] = r s de co( . . . ) outputs the number er r , whi ch speci fi es the
number of err ors that occurr ed i n the decodi ng of the message.
[ ms g, er r , cc ode] = r s de co( . . . ) outputs the cor rected c ode. The format of
cc ode matches the format of code i n the i nput.
[ ms g, er r , cc ode, c er r ] = r s de co( . . . ) outputs the number ce r r , whi ch
speci fi es the number of er ror s found i n cc ode col umn.
Example Exampl e of usi ng r s e nco and r s de co for err or-control codi ng:
l = 1000; % Bi t numbe r i n cal c ul at i on.
m = 4;
n = 2^m 1; % Set c odewor d l engt h
k = n 4; % Set Numbe r of i nf or mat i on bi t s , e r r or
%c or r ec t i on c apabi l i t y .
ms g = r andi nt ( l , 1) ; % Tes t i ng 1000 bi t s t r ans f e r .
t p = gf t upl e ( [ 1 : n1] ' , m) ; % Ge ne r at e t he el ement s i n
% gf ( 2^m) .
[ code , added] = r s e nc o( ms g, t p, k) ; % Enc ode.
noi = r and( l engt h( code ) /m, 1) < . 03; % Add 3% noi s e.
noi = ( noi one s ( 1, m) ) ' ;
noi = noi ( : ) ; % Cons t r uct noi s e f or bur s t er r or .
c ode_noi = r em( c ode + noi , 2) ; % Add noi s e.
[ de c, er r , cc ode , e r r _c ] = r s dec o( code _noi , t p, k) ; % De code .
ms g = [ ms g; z e r os ( adde d, 1) ] ; % Pad ms g l e ngt h f or compar i s on.
max ( abs ( dec ms g) ) % Compar e r e ce i v ed t o t r ans mi t t ed
% me s s age .
x = [ 1: l e ngt h( noi ) ] ; % x - axi s f or noi s e.
z =[ 1: mn: l e ngt h( noi ) ] ;
y =z er os ( 1, l e ngt h( z ) ) ;
rsdeco
5-140
z =[ z ; z ] ;
y =[ y+mi n( e r r _c ) ;
y +max ( e r r _c) ] ;
s ubpl ot ( 211) ;
pl ot ( x, noi , ' yo' , x, er r _c , ' r x ' , z , y, ' g- ' ) ; % Pl ace d vs . de t ec t e d
e r r or .
t i t l e ( ' er r or det ec t i on r e cor d' ) ;
x l abe l ( ' o- - pl ace d er r or ; x - - de t e ct e d er r or ; ve r t i cal bar : r s - dec o
s ec t i on. ' ) ;
axi s ( [ 1, l e ngt h( noi ) , mi n( e r r _c ) , max ( e r r _c ) ] ) ;
x = [ 1: l e ngt h( ms g) ] ; % x- ax i s f or ms g.
z = [ 1: mk: l engt h( ms g) ] ;
y =z er os ( 1, l e ngt h( z ) ) ;
z =[ z ; z ] ;
y =[ y; y+max ( ms g) ] ;
s ubpl ot ( 212) ;
pl ot ( x, ms g, ' yo' , x, de c, ' r x ' , z , y, ' g- ' ) ;
t i t l e ( ' me s s age and dec ode d s i gnal compar i s on' ) ;
x l abe l ( ' o- - or i gi nal me s s age ; x- - de code d r e s ul t . ' ) ;
axi s ( [ 1, l e ngt h( ms g) , mi n( mi n( ms g) ) , max( max( ms g) ) ] ) ;
Thi s exampl e i s a two-er ror cor recti on case. I f fewer than two bur st er ror s occur
between the i ndi cati on l i nes on the pl ot, the method i s abl e to cor rect the er ror.
See Also r s pol y, r s e nco, r s de c ode, e nc ode , de code
rsdecode
5-141
rsdecode
Purpose Reed-Sol omon decodi ng for data i n the exponenti al vector i nput/output for mat
Syntax ms g = r s dec ode( c ode, k) ;
ms g = r s dec ode( c ode, k, t p) ;
[ ms g, er r ] = r s de code ( . . . ) ;
[ ms g, er r , cc ode] = r s de code ( . . . ) ;
Description Thi s functi on accepts codewords i n the exponenti al i nput for mat. For exampl e
represents i n GF(2
m
), where m i s a posi ti ve
i nteger. Ther e ar e 2
m
el ements i n GF(2
m
). Hence, the i nput code represents
2
m
(2
m
1) bi ts of i nfor mati on. The decoded ms g repr esents 2
m
k bi ts of
i nfor mati on.
ms g = r s dec ode( c ode, k) r ecover s the message i nfor mati on from codewor d
code. code must be the output of r s enc o, whi ch uses Reed-Sol omon encodi ng
techni que. c ode i s a matr i x wi th a r ow l ength n = 2m 1, wher e m i s a posi ti ve
i nteger no l ess than 3. k i s the number of i nformati on bi ts, whi ch i s usual l y an
odd number. The er ror-corr ecti on capabi l i ty of a Reed-Sol omon code i s t =
f l oor ( ( nk) /2) . The recover ed message stor ed i n ms g; the row number of ms g
i s the same as the row number of c ode . The col umn number of ms g i s k.
ms g = r s c ode( code, k, t p) recovers the l ength k message fr om codewor d c ode
wi th the el ements of GF(2
m
) speci fi ed i n t p. To speed up the process, we
recommend thi s format even i f the GF(2
m
) i s a defaul t for mat. You can
gener ate a defaul t t p by usi ng:
t p = gf t upl e ( [ 1: 2m2] ' , m)
[ ms g, er r ] = r s de code ( . . . ) provi des the er ror cor recti on i nfor mati on. A
non-negati ve i nteger i n e r r i ndi cates the number of err ors cor rected; a
negati ve i nteger i ndi cates that there ar e mor e er rors i n the codeword than can
be corr ected.
[ ms g, er r , cc ode] = r s de code ( . . . ) outputs the corr ected codeword.
See Also enc ode, dec ode , r s de co
I nf 0 1 2 ...
0 1
2
...
rsdecof
5-142
rsdecof
Purpose Reed-Sol omon decodi ng for an encoded ASCI I fi l e
Syntax r s dec of ( f i l e_i n, f i l e _out ) ;
r s dec of ( f i l e_i n, f i l e _out , er r _cor ) ;
Description Thi s functi on i s the i nver se pr ocess of the functi on r s e nc of . I t decodes an
r s e nc of encoded fi l e.
r s dec of ( f i l e_i n, f i l e _out ) decodes an ASCI I fi l e f i l e_i n, whi ch must be
the output of r s e nc of . The codewor d and message l engths are fi xed at 127 and
117, respecti vel y. The err or-cor recti on capabi l i ty i s 5 for every 117 message
char acter s and 127 codeword character s. The decoded message i s wri tten to
f i l e_out . Both f i l e _i n and f i l e_out ar e stri ng var i abl es.
r s dec of ( f i l e_i n, f i l e _out , er r _cor ) speci fi es the err or -cor recti on
capabi l i ty for ever y 127 codewords. The message l ength i s 127 2e r r _c or .
The val ue i n e r r _c or must match the val ue used i n r s encof .
See Also r s e nc of , enc ode, dec ode
rsenco
5-143
rsenco
Purpose Reed-Sol omon encodi ng wi th var i ous i nput/output for mats
Syntax code = r s enco( ms g, n, k) ;
code = r s enco( ms g, n, k, t ype_f l ag) ;
code = r s enco( ms g, n, k, t ype_f l ag, pg) ;
[ c ode , added] = r s e nc o( . . . ) ;
Description Reed-Sol omon code i s speci al l y desi gned to corr ect burst err ors i nstead of
random er rors. The functi on i s desi gned to be abl e to take bi nary, deci mal (non-
negati ve i ntegers), and power for mats.
code = r s enco( ms g, n, k) encodes the bi nary message i n msg by usi ng
codewor d l ength n, and number of i nfor mati on bi ts k. A val i d Reed-Sol omon
code shoul d has i ts codeword l ength n = 2m1, where m i s an i nteger no l ess than
3 and shoul d have i ts number of i nfor mati on bi ts k < n. The i nput vari abl e ms g
can be ei ther a col umn vector wi th l ength L; or a L-by-m matri x. For the former
ms g i nput, the output code i s a Lc1 col umn vector wi th Lc1=c ei l ( L/m/k) mn.
For the l atter ms g i nput, the output code i s a Lc 2-by-m matri x wi th
Lc 2=c ei l ( L/k) n. To speed up the cal cul ati on, par ameter n can be changed to
a l i st of al l el ements i n GF(2
m
), a 2
m
-by-m matri x.
code = r s enco( ms g, n, k, t ype_f l ag) speci fi es the format of ms g by usi ng the
str i ng vari abl e t ype_f l ag. Ther e ar e three opti ons for t t y pe _f l ag:
' bi nar y' , the defaul t opti on, speci fi es that the el ements of code ar e i n bi nary
for mat.
' dec i mal ' speci fi es that the el ements i n ms g ar e base 10 i ntegers i n the r ange
[0, n].
' power ' speci fi es that the el ements of c ode ar e i n the power format for
GF(2
m
). See the Tutorial for a di scussi on of the power for mat for Gal oi s
fi el ds. The el ements i n thi s repr esentati on ar e I nf and the i ntegers 0 to n1.
Any negati ve number i n thi s for m i s equi val ent to I nf.
rsenco
5-144
I n ei ther the ' dec i mal ' or ' power ' case, the el ements i n c ode must match the
code type. I n both these cases, code can be ei ther:
A l ength L col umn vector, i n whi ch case the output ms g i s an Lc col umn vec-
tor wi th Lc = Lk/n.
An L-by-n matr i x (note the di mensi ons ar e di fferent fr om the ' bi nar y ' case,
i n whi ch case the output c ode i s a L-by-k matr i x.
c ode = r s enco( ms g, n, k, t ype_f l ag, pg) speci fi es the generator pol ynomi al of
the Reed-Sol omon code.
[ code , added] = r s enco( . . . ) outputs the number added, whi ch i s the number
of the el ements added to ms g based on whi chever ms g for mat i t i s.
The output c ode type wi l l match the i nput ms g data type. I n the computati on
i n thi s functi on, the type i s converted i n the order as fol l ows:
For the message format;
For the codeword format:
See Also r s dec o, e nc ode , de code
ms g: bi nar y deci mal
power
c ode:
bi nar y deci mal power
rsencode
5-145
rsencode
Purpose Reed-Sol omon encodi ng for data i n the exponenti al vector i nput/output for mat
Syntax code = r s encode ( ms g, pg, n) ;
Description code = r s encode ( ms g, pg, n) encodes the message ms g usi ng Reed-Sol omon
code techni que. pg i s the generator pol ynomi al . n i s the codeword l ength. The
decode pai r for thi s functi on i s r s dec ode .
Note that the el ements of ms g, pg, and c ode ar e i n GF(2
m
) power for m.
See Also r s dec ode, e nc ode , de code, r s pol y
rsencof
5-146
rsen cof
Purpose Reed-Sol omon encodi ng for an ASCI I fi l e
Syntax r s e nc of ( f i l e_i n, f i l e _out ) ;
r s e nc of ( f i l e_i n, f i l e _out , er r _cor ) ;
Description r s e nc of ( f i l e_i n, f i l e _out ) encodes an ASCI I fi l e speci fi ed i n f i l e_i n usi ng
(127, 117) Reed-Sol omon code. The err or-cor recti on capabi l i ty of thi s code i s 5
(for every 127 char acter s). Thi s functi on wr i tes the encoded text to fi l e
f i l e_out . Both f i l e _i n and f i l e_out ar e stri ng var i abl es.
r s e nc of ( f i l e_i n, f i l e _out , er r _cor ) speci fi es the er ror corr ecti on capabi l i ty
for each 127 codewords. The message l ength i s 1272e r r _c or .
See Also r s dec of , enc ode, dec ode
rspoly
5-147
rspol y
Purpose Produce a Reed-Sol omon code gener ator pol ynomi al
Syntax Pg = r s pol y ( n, k) ;
Pg = r s pol y ( n, k, t p) ;
[ Pg, t ] = r s pol y ( . . . ) ;
Description Reed-Sol omon code i s a bur st-err or corr ecti on code. The codeword l ength of a
Reed-Sol omon code i s n=2
m
1 where m i s a posi ti ve number l ar ger or equal to 3.
The number of i nformati on bi ts k i s a posi ti ve number l ess than n. The er ror
cor recti on capabi l i ty of a Reed-Sol omon code i s t = f l oor ( ( nk) /2) . Si nce n i s
an odd number , for effi ci ency of the codi ng, we recommend that k i s an odd
number al so.
Pg = r s pol y ( n, k) outputs the generator pol ynomi al Pg of a Reed-Sol omon code
wi th codeword l ength n, number of i nformati on bi ts k. The output Pg i s a
pol ynomi al i n GF(2
m
). Each el ement i s repr esented by a power form.
Pg = r s pol y ( n, k, t p) produces generator pol ynomi al usi ng the speci fi ed
GF(2
m
) wi th i ts compl ete el ement l i sted i n t p. t p i s a (n+1)-by-m matri x wher e
n=2
m
1. Thi s parameter speeds up the cal cul ati on. When t p i s a scal ar , i t
speci fi es m.
[ Pg, t ] = r s pol y ( . . . ) outputs the er ror-corr ecti on capabi l i ty of the
Reed-Sol omon code.
Examples The (15, 11) Reed-Sol omon code gener ator pol ynomi al can be obtai ned by
r s pol y( 15, 11)
ans =
10 3 6 13 0
whi ch means that the generator pol ynomi al i s
See Also enc ode, dec ode , r s enco, r s dec o

10

3
X
6
X
2

13
X
3
X
4
+ + + +
sim2gen
5-148
si m2gen
Purpose Produce a convol uti onal code transfer functi on i n octal form
Syntax gen = s i m2gen( s i m_f i l e )
Description s i m2gen uses Si mul i nk to defi ne a speci fi c str uctur e of the convol uti onal code.
The bl ocks used i n bui l di ng a convol uti onal code are:
The edi ted convol uti onal bl ock i s used as an user i nter face onl y. You cannot use
i t for si mul ati on pur pose.
gen = s i m2gen( s i m_f i l e ) r eads i n a Si mul i nk bl ock di agr am i n bui l di ng a
convol uti onal code structur e and outputs to a octal for m transfer functi on
matr i x. The defi ni ti on of an octal for m tr ansfer functi on i s defi ned i n the
descr i pti on for the functi on oct 2ge n. s i m_f i l e i s a str i ng that i s the
convol uti onal code Si mul i nk bl ock di agram fi l ename.
memory bl ocks Ser ve as the regi ster bl ocks i n convol uti onal code.
The i ni ti al condi ti on of the code i s al ways set to be
zero no matter what par ameters have been set i n
the Si mul i nk memory bl ock entr y.
XOR l ogi c I s the excl usi ve OR l ogi c i n a convol uti onal code
structure.
i npor t bl ock Accepts the i nput. The i npor t number r epresents
the sequenti al number of the i nput swi tch.
outpor t bl ock Defi nes the output sequence on the output si de.
sim2gen
5-149
Example We take (3,2,2) convol uti onal code as an exampl e. The structure of the code i s
taken from Fi gur e 10.9 i n reference . Thi s fi gure shows the Si mul i nk bl ock
di agr am gener ated by s i m2ge n:
Figure 5-1: Simulink Block Diagram for (3,2,2) Convolutional Code
Thi s Si mul i nk bl ock di agr am i s saved i n f i g_10_9. m. Usi ng the functi on
s i m2gen, the octal form of the transfer functi on can be obtai ned by usi ng the
command:
gen = s i m2ge n( f i g_10_9 )
gen =
Limitation No l oops ar e al l owed i n the convol uti onal code str ucture. Use s i m2t r an i f ther e
ar e feedback l oops i n the convol uti onal code str uctur e. Onl y the memory, XOR,
I nport, and outport bl ocks are al l owed i n the Si mul i nk di agram. The Si mul i nk
bl ock di agr am used for thi s functi on cannot be used i n Si mul i nk si mul ati on.
See Also oc t 2gen, s i m2t r an, s i m2l og, gen2abcd, encode, dec ode
1
Inport
1
Outport
XOR
Logical
Operator1
Memory
XOR
Logical
Operator2
Memory1
XOR
Logical
Operator3
2
Outport1
3
Outport2
2
Inport1
4 0 7
0 4 5
sim2logi
5-150
si m2l ogi
Purpose Gener ate a nonl i near convol uti onal code transfer functi on
Syntax gen = s i m2gen( s i m_f i l e ) ;
Description Thi s functi on i s a l ower l evel functi on used cal l ed by the functi on s i m2t r an.
s i m2l ogi bui l ds a nonl i near convol uti onal code transfer functi on. Pl ease refer
the reference page for s i m2t r an for a descri pti on of nonl i near tr ansfer functi on
and an exampl e of the constructi on of a nonl i near transfer functi on. Thi s
functi on uses the Si mul i nk del ay bl ock as a r egi ster i n bui l di ng nonl i near
tr ansfer functi ons.
gen = s i m2l ogi ( s i m_f i l e) reads i n a Si mul i nk bl ock di agram to bui l d a
convol uti onal code structure and outputs a nonl i near transfer functi on matr i x.
The transfer functi on i s r epresented i n a nonl i near system for m. A nonl i near
system can be wr i tten as the di fference equati on:
where u(k) i s the i nput vector, x(k) i s the state, and y(k) i s the output vector .
gen i s a two-col umn matr i x. The contents of the output ge n are:
where N i s the output vector l ength, K i s the i nput vector l ength, Mi s the state
l ength, and U and V ar e col umn vectors wi th thei r l ength as 2
K+M
.
Limitation You can onl y use the Si mul i nk uni t del ay bl ock to r epr esent the r egi ster . Any
other bl ocks wi th memory i n the bl ock di agram may cause err ors i n the
gener ati on of the nonl i near tr ansfer functi on. Thi s i s because there i s no
speci fi c way to di sti ngui sh the order of the r egi sters. The Si mul i nk bl ock
di agr am used for thi s functi on cannot be used i n Si mul i nk si mul ati on.
See Also e nc ode, dec ode , s i m2gen, s i m2t r an, gen2abcd
x k 1 + ( ) f x k ( ) u k ( ) , ( ) =
y k ( ) g x k ( ) u k ( ) , ( ) =
gen
Inf N
M K
U V
=
sim2tran
5-151
si m2tr an
Purpose Produce a l i near or a nonl i near convol uti onal code tr ansfer functi on
Syntax ge n = s i m2t r an( s i m_f i l e) ;
Description s i m2t r an uses Si mul i nk to defi ne a speci fi c structure of the convol uti onal code.
The transfer functi on can be ei ther a l i near transfer functi on or a nonl i near
functi on.
Linear Transfer Function
The bl ocks used i n bui l di ng a l i near convol uti onal code tr ansfer functi on are:
The edi ted convol uti onal bl ock i s used as an user i nter face onl y. You cannot use
the bl ock di agr am for si mul ati on purposes.
ge n = s i m2t r an( s i m_f i l e) reads i n a Si mul i nk bl ock di agram to bui l d a
convol uti onal code structure and outputs a transfer functi on matri x. The
tr ansfer functi on i s repr esented i n a l i near system for m, whi ch can be wri tten
as a di ffer ence equati on:
memory bl ocks Ser ve as the r egi ster bl ocks i n convol uti onal code.
The i ni ti al condi ti on of the code i s al ways set to be
zero no matter what parameter s have been set i n
the Si mul i nk memory bl ock entr y.
XOR l ogi c I s the excl usi ve OR l ogi c i n a convol uti onal code
structure.
i npor t bl ock Accepts the i nput. The i mport number repr esents
the sequenti al number of the i nput swi tch.
outpor t bl ock Defi nes the output sequence on the output si de.
x k 1 + ( ) Ax k ( ) Bu k ( ) + =
y k ( ) Cx k ( ) Du k ( ) + =
sim2tran
5-152
where u(k) i s the i nput vector, x(k) i s the state, and y(k) i s the output vector .
Mul ti pl i cati on and addi ti on are bi nary cal cul ati ons. Thi s functi on outputs the
tr ansfer functi on i n thi s for m:
where V i s a col umn vector wi th i ts fi rst three el ement bei ng the output vector
l ength, the i nput l ength, and the state vector l ength. The l ast el ement of the
vector i s assi gned to be -I nf.
Nonlinear Transfer Function
The bl ocks used i n bui l di ng a convol uti onal code are:
You cannot use any other Si mul i nk bl ocks to bui l d a convol uti onal code bl ock
di agr am. The convol uti onal code bl ock di agr am cannot be used for si mul ati on
pur poses.
gen = s i m2t r an( s i m_f i l e) reads i n a Si mul i nk bl ock di agram i n bui l di ng a
convol uti onal code structure and outputs a nonl i near transfer functi on matr i x.
uni t del ays Ser ve as r egi ster bl ocks i n convol uti onal code. The
i ni ti al condi ti on of the code i s al ways set to be zero
no matter what par ameters have been set i n the
Si mul i nk memory bl ock entr y. The sampl e ti me i s
di sr egar ded i n generati ng the tr ansfer functi on.
XOR l ogi c I s the excl usi ve OR l ogi c i n a convol uti onal code
structure.
AND l ogi c I s the bi nar y mul ti pl i cati on l ogi c i n a convol uti onal
code str uctur e.
i npor t bl ock Accepts the i nput. The i mport number r epr esents
the sequenti al number of the i nput swi tch.
outpor t bl ock Defi nes the output sequence i n the output si de.
gen
A
C
B
D
V
=
sim2tran
5-153
The transfer functi on i s repr esented i n a nonl i near system form, whi ch can be
wr i tten as a di ffer ence equati on:
where u(k) i s the i nput vector, x(k) i s the state, and y(k) i s the output vector .
gen i s a two-col umn matr i x. The contents of the output transfer functi on gen
ar e:
where N i s the output vector l ength, K i s the i nput vector l ength, M i s the state
l ength, and U and V are col umn vector s wi th thei r l ength equal to 2
K+M
.
See the Tutorial for a di scussi on of nonl i near transfer functi ons i n
convol uti onal code.
Examples Thi s secti on provi des two exampl es, a l i near tr ansfer functi on exampl e and a
nonl i near transfer functi on exampl e. Note the di fferent bl ocks used i n bui l di ng
the l i near and nonl i near tr ansfer functi ons.
x k 1 + ( ) f x k ( ) u k ( ) , ( ) =
y k ( ) g x k ( ) u k ( ) , ( ) =
gen
Inf N
M K
U V
=
sim2tran
5-154
Linear Transfer Function
We take (3,2,2) convol uti onal code as an exampl e. A Si mul i nk bl ock di agram i s
bui l t as shown i n the fi gure.
The Si mul i nk bl ock di agram i s saved as fi l e f i g_10_9. m. Usi ng the functi on
s i m2t r an, the transfer functi on can be obtai ned by typi ng the command:
gen = s i m2t r an( ' f i g_10_9' )
gen =
Usi ng the command ge n2abc d, you can further fi nd [ A, B, C, D] matr i ces i n
the descri pti on.
1
Inport
1
Outport
XOR
Logical
Operator1
Memory
XOR
Logical
Operator2
Memory1
XOR
Logical
Operator3
2
Outport1
3
Outport2
2
Inport1
0 0 1 1 3
1 0 1 0 2
0 0 1 0 2
0 0 0 1 0
0 1 1 1 I nf
sim2tran
5-155
Nonlinear Transfer Function
We take (3,2,2) convol uti onal code as an exampl e. The structure of the code i s
shown i n the fi gure.
The Si mul i nk bl ock di agram i s saved as fi l e nl conc d. m. Usi ng the functi on
s i m2t r an, the transfer functi on can be obtai ned by typi ng the command:
gen = s i m2t r an( ' nl conc d' )
gen' =
Limitation To bui l d a l i near convol uti onal code, you can use onl y the memor y, XOR,
I nport, and Outport bl ocks i n the Si mul i nk di agram. The Si mul i nk bl ock
di agr am used for thi s functi on cannot be used i n Si mul i nk si mul ati on.
To bui l d a nonl i near convol uti onal code transfer functi on, you can use onl y the
uni t del ay bl ock to r epr esent the r egi ster . Any other bl ocks wi th memory i n the
bl ock di agr am may cause er ror s.
There i s no speci fi c way to di sti ngui sh the or der of the r egi ster s. The Si mul i nk
bl ock di agr am used for thi s functi on cannot be used i n Si mul i nk si mul ati on.
See Also s i m2gen, s i m2l ogi , gen2abcd, encode, dec ode
1
Inport
1/z
XOR
2
Inport1
2
Outport1
1
Outport
3
Outport2
XOR
AND
1/z
I n f 2 0 0 1 3 3 1 2 2 2 2 3 1 1 3 0 0
3 2 0 4 0 4 1 5 1 5 2 6 2 6 3 7 3 7
symerr
5-156
symerr
Purpose Compare el ements i n two matr i ces to fi nd the number of di fferences and the
rati o of the number of di ffer ences to the di mensi on of the matr i ces
Syntax [ numb, r at i ] = s y me r r ( x , y ) ;
[ numb, r at i ] = s y me r r ( x , y , di r e ct ) ;
Description s ymer r compar es two matri ces of equal di mensi ons and fi nds the number of
el ements that do not agree. I t al so cal cul ates the r ati o of the number of
el ements that di ffer to the di mensi on of the matri ces. Her e i f the matr i ces are
m-by-n, the di mensi on i s defi ned to be mn.
di r ec t = ' r ow' or ' c ol umn' speci fi es i n whi ch di recti on the compar i son i s to
occur .
Examples See exampl e i n bi t e r r .
See Also bi t er r
vec2mat
5-157
vec2mat
Purpose Conver t a vector i nto a matr i x
Syntax mat = v ec 2mat ( v e c, m) ;
mat = v ec 2mat ( v e c, m, ad_t o) ;
[ mat , er r ] = v ec 2mat ( . . . ) ;
Description mat = v ec 2mat ( ve c, m) converts vector ve c i nto an m col umn matri x wi th r ow
pri or i ty ar rangement. I f the l ength of v ec i s not mul ti pl e of m, the functi on adds
0 to the matri x. The col umn number of the matri x equal s:
c ei l ( l e ngt h( ve c) , m)
mat = v ec 2mat ( v e c, m, ad_t o) speci fi es the el ements to be added. Var i abl e
ad_t o can be a vector or matri x. Thi s functi on takes onl y the necessar y number
of el ements fr om ad_t o to make the matri x. The extra el ements i n ad_t o are
di sr egar ded.
[ mat , er r ] = v ec 2mat ( . . . ) outputs an i nteger er r , whi ch i ndi cates how many
el ements has been added to make the matri x.
viterbi
5-158
vi terbi
Purpose Decodi ng of convol uti onal code usi ng the Vi ter bi al gor i thm
Syntax ms g = v i t er bi ( code , t r an_f unc) ;
ms g = v i t er bi ( code , t r an_f unc, me mor y _l e ngt h) ;
ms g = v i t er bi ( code , t r an_f unc, me mor y _l e ngt h, t r an_pr ob) ;
ms g = v i t er bi ( code , t r an_f unc, me mor y _l e ngt h, t r an_pr ob, pl ot _f l ag) ;
[ ms g, me t r i c ] = v i t er bi ( . . . ) ;
[ ms g, me t r i c , s ur v i v or ] = v i t er bi ( . . . ) ;
Description v i t er bi recover s the message ms g fr om the recei ved codeword, whi ch must be
i n the convol uti onal code for mat. The Vi ter bi al gor i thm i s a maxi mum
l i kel i hood method desi gned to detect messages from codewords. Thi s functi on
can al so gener ate tr el l i s pl ots used to anal yze the detecti on process.
ms g = v i t er bi ( code , t r an_f unc) uses the Vi terbi al gori thm to r ecover the
message i n c ode wi th the tr ansfer functi on matr i x provi ded i n t r an_f unc .
t r an_f unc can be a l i near , nonl i near , or octal form. See functi on oct 2gen for
the format of the octal form of a tr ansfer matri x, s i m2gen for the l i near format,
and s i m2l ogi for the nonl i near for mat. code i s a N col umn matr i x r ecei ved i n
a bi nary symmetr i c channel (BSC). Al l el ements i n code are ei ther one or zer o.
ms g i s a K col umn matr i x. The row number of ms g wi l l be the row number of
code mi nus (M- 1).
ms g = v i t er bi ( code , t r an_f unc, me mor y _l e ngt h) speci fi es the maxi mum
memory l ength i n the decodi ng pr ocess by an i nteger number memor y_l engt h.
The decode makes a deci si on based on the best metri c i n the l i mi ted memor y
l ength. As a r ul e of thumb, when the memory l ength i s defi ned not l ess than
5KM, the deci si on i s ver y cl ose to opti mal . When memor y_l e ngt h i s defi ned
l ess or equal s to zero, the me mor y _l engt h i s consi dered as no l i mi t.
ms g = v i t er bi ( c ode , t r an_f unc , me mor y _l engt h, t r an_pr ob) r ecover s the ms g
usi ng the tr ansfer pr obabi l i ty pr ovi ded i n t r an_pr ob. t r an_pr ob i s a thr ee row
matr i x. The fi r st row speci fi es the r ecei vi ng range, the second row the
viterbi
5-159
probabi l i ty of a zero tr ansmi ssi on to the recei vi ng range, and the thi rd r ow the
probabi l i ty of si gnal one tr ansfer i ng to the recei vi ng range. For exampl e,
means that si gnal 0 has 2/5 pr obabi l i ty bei ng r ecei ved i n range (I nf, 1/10], 1/
3 i n range (1/10, 1/2], 1/5 i n r ange (1/2, 9/10], and 1/15 i n range (9/10, I nf).
Si gnal 1 has 1/16 probabi l i ty bei ng r ecei ved i n range (I nf, 1/10], 1/8 i n r ange
(1/10, 1/2], 3/8 i n range (1/2, 9/10], and 7/16 i n r ange (9/10, I nf). The tabl e bel ow
i l l ustr ates the transi ti on pr obabi l i ti es speci fi ed i n the t r an_pr ob matri x:
A tree di agram bel ow i s another way of organi zi ng the probabi l i ty data:
code i s tr ansmi tted i n a di scr ete memoryl ess channel (DMC). When t r an_pr ob
i s si mpl y a non-matri x scal ar, the par ameter i s i gnored. I n case of t r an_pr ob
i s i gnored, c ode must be tr ansmi tted i n BSC.
Recei vi ng r ange (I nf, 1/10] (1/10, 1/2] (1/2, 9/10] (9/10, I nf)
Si gnal zero transfer
probabi l i ty
2/5 1/3 1/5 1/15
Si gnal one transfer
probabi l i ty
1/16 1/8 3/8 7/16
tran_prob
I nf
1
10
------
1
2
---
9
10
------
2
5
---
1
3
---
1
5
---
1
15
------
1
16
------
1
8
---
3
8
---
7
16
------
=
0
1
(-I nf, 1/10]
(1/10, 1/2]
(1/2, 9/10]
(9/10, I nf)
2/5
1/3
1/5
1/15
1/16
1/8
3/8
7/16
viterbi
5-160
ms g = v i t er bi ( code , t r an_f unc, me mor y _l e ngt h, t r an_pr ob, pl ot _f l ag)
pl ots the trel l i s when pl ot _f l ag i s a posi ti ve i nteger . When pl ot _f l ag i s l ess
or equal to zer o, thi s parameter i s i gnor ed. The functi on opens a fi gure wi th the
fi gure number equal to the val ue of pl ot _f l ag. The trel l i s fi gur e has the ti me
as x-axi s and tr ansfer state as y-axi s. The whi te l i nes are the possi bl e tr ansfer s.
The yel l ow l i nes ar e the survi vors i n a si ngl e step cal cul ati on. The r ed l i nes are
the fi nal survi vor path. The number s at the state poi nts are the metri c val ues
(when t r an_pr ob i s not speci fi ed, the numbers ar e Hammi ng di stance val ues).
[ ms g, me t r i c ] = v i t er bi ( . . . ) outputs the metr i c val ue i n the cal cul ati on.
When t r an_pr ob i s not speci fi ed, me t r i c outputs the Hammi ng di stance i n the
cal cul ati on.
[ ms g, me t r i c , s ur v i v or ] = v i t er bi ( . . . ) outputs the codewor d i n the
survi vor path.
Examples Assume the transfer channel has the tr ansfer pr obabi l i ty as shown i n the
fol l owi ng fi gur e.
The transfer probabi l i ty matr i x i s as fol l ows.
t r an_pr ob = [
I nf , . 1 . 5 . 9
. 4 . 3 . 2 . 1
. 1 . 2 . 3 . 4] ;
Assume the recei ver have recei ved the fol l owi ng si gnal
r = [ 1 . 8 0; 1 1 . 2; 1 1 0; 1 1 1; 0 . 8 0; . 8 . 2 0; . 8 0 1] ;
The convol uti onal transfer functi on matr i x i s a (3, 1, 2) str uctur e wi th the octal
form of the tr ansfer functi on bei ng:
t r an_f unc = [ 6 5 7] ;
0
1
(-I nf, 0.1]
(0.1, 0.5]
(0.5, 0.9]
(0.9, I nf)
.4
.3
.2
.1
.1
.2
.3
.4
viterbi
5-161
Usi ng functi on v i t er bi , assumi ng the memor y l ength i s 5, the maxi mum
l i kel i hood recover ed message ms g, the metr i c mt c , and the sur vi vor s s uv can be
cal cul ated by the fol l owi ng l i ne:
[ ms g, mt c, s uv ] = vi t e r bi ( r , t r an_f unc , 5, t r an_pr ob, 1) ;
The trel l i s fi gur e gener ated fr om the command i s shown i n the fi gure on the
next page. The sur vi vor s are:
s uv = [ 1 1 1; 0 1 0; 1 1 0; 0 1 1; 0 0 0; 0 0 0; 0 0 0] ;
The exampl e i s modi fi ed fr om exampl e 11.1 i n Refer ence .
Figure 5-2: A Trellis Path
The thi cker l i nes for m the path of the survi vor s.
0 State 0
State 2
State 1
State 3
Time
2.097
1.921
4.62
3.592
4.018
3.842
6.416
5.814
5.035
5.388
6.831
7.433
7.184
7.786
8.326
9.28
9.706
8.752
9.946
10.55
10.37
10.97
12.0
viterbi
5-162
See Also s i m2gen, oc t 2gen, conve nc o, e nc ode , de code
Algorithm The dynami c progr ammi ng method i s used i n the computati on i n thi s functi on.
See the Tutorial for a di scussi on of the i mpl ementati on of thi s al gor i thm.

6
Si mul i nk Bl ock
Li brary Reference
Sources and Sinks in Communication Systems . . . . 6-4
Source Coding . . . . . . . . . . . . . . . . . . . 6-38
Error-Control Coding . . . . . . . . . . . . . . . . 6-53
Modulation and Demodulation . . . . . . . . . . . 6-110
Signal Multiple Access . . . . . . . . . . . . . . 6-235
Transmitting and Receiving Filters. . . . . . . . . 6-249
Channels. . . . . . . . . . . . . . . . . . . . . 6-261
Synchronization . . . . . . . . . . . . . . . . . 6-275
Utilities . . . . . . . . . . . . . . . . . . . . . 6-285
6 Sim ulink Block Library Reference
6-2
The Si mul i nk bl ock l i br ar y of the Communi cati ons Tool box i s shown bel ow.
The structure of the l i brar y i s ar ranged as a hi gh l evel over vi ew bl ock di agr am
of a typi cal si ngl e di recti on transmi tti ng communi cati on system. Each bl ock i n
thi s l i brar y contai ns a subl i br ary. A subl i brary wi ndow opens when you
doubl e-cl i ck on a bl ock i n thi s l i brary.
Figure 6-1: The Simulink Block Library of The Communications Toolbox
Thi s fi gure contai ns a compr ehensi ve set of communi cati on subsystems. A
speci fi c i mpl ementati on of a communi cati on system may contai n onl y some of
the subsystems pr ovi ded i n the Si mul i nk bl ock l i brar y.
I n communi cati on systems, tr ansmi ssi on and recei vi ng techni ques ar e used
together . I n most, but not al l , cases, i f a techni que i s used i n the transmi tti ng
si de, the same techni que shoul d be used i n the recei vi ng si de. For exampl e, i f
an ampl i tude modul ati on method i s used i n the transmi ssi on si de, then an
ampl i tude demodul ati on method must be used i n the r ecei vi ng si de i n order to
recover the ori gi nal si gnal cor rectl y. Because the methods are used i n pai rs, the
transmi tti ng and r ecei vi ng bl ocks i n the same categor y are arr anged i nto the
same subl i brar y. For exampl e, doubl e-cl i cki ng the Er ror-Control Codi ng bl ock
6-3
or the Er ror -Control Decodi ng bl ock opens the same bl ock l i brary wi ndow. Thi s
chapter di scusses the fol l owi ng subl i br ar i es i n the Si mul i nk bl ock l i brar y:
Sources and Si nks of Communi cati on Systems
Source Codi ng i n Transmi tti ng and Recei vi ng
Err or -Contr ol Encodi ng and Decodi ng
Si gnal Modul ati on and Demodul ati on
Mul ti pl e Access i n Tr ansmi tti ng and Recei vi ng
Tr ansmi tti ng and Recei vi ng Fi l ters
Channel
Synchr oni zati on
Uti l i ti es
Err or Anal ysi s
The l ast i tem, Er ror Anal ysi s, i s not shown i n the fi gur e6-1. The functi ons i n
thi s categor y are avai l abl e onl y usi ng MATLAB functi ons.
I n the Communi cati ons Tool box Si mul i nk bl ock l i br ary, there are two ki nds of
bl ocks: functi on bl ocks and exampl e bl ocks. Functi on bl ocks ar e r eady-to-use
bl ocks for speci fi c appl i cati ons. Exampl e bl ocks are cyan col or ed bl ocks wi th no
i nput or output por ts. Thi s tool box provi des exampl e/demo bl ocks to show how
to use the functi on bl ocks. A bl ock di agram wi ndow opens when you
doubl e-cl i ck on an exampl e/demo bl ock.
Most of the bl ocks i n the Si mul i nk bl ock l i brar y use maski ng. You can
unmask any bl ock to fi nd the detai l s of the i mpl ementati on. You can al so
change the bl ock i mpl ementati on to meet your speci fi c appl i cati on needs.
6 Sim ulink Block Library Reference
6-4
Sources and Sinks in Communication Systems
I n a communi cati on system, si gnal sour ce, storage, and di spl ay pl ay ver y
i mportant rol es. A si gnal source can be an anal og si gnal , a di gi tal si gnal , a
var i abl e, or a computer data fi l e. The task of the transmi tti ng si de of a
communi -cati on system i s to convert i nfor mati on i nto a si gnal that can then
transmi t through the communi cati on channel . The recei vi ng si de r equi r es
stor age and di spl ay el ements. Communi cati ons engi neers often store recei ved
si gnal s i n such a way that the recei ved si gnal i s avai l abl e for r ecal l at any ti me.
Sources and Sinks in C om m unication System s
6-5
There are a number of speci al pl ots for communi cati on system anal ysi s. Thi s
tool box i ncl udes some of the most frequentl y used pl ots, such as eye-pattern,
scatter , and err or -rate meter. Thi s fi gur e shows the Source and Si nk
Subl i br ary:
Figure 6-2: Source and Sink Sublibrary
6 Sim ulink Block Library Reference
6-6
Sources and Sinks Reference Table
Thi s tabl e l i sts the Si mul i nk bl ocks i n the Sour ces and Si nks subl i br ar y. (They
are l i sted al phabeti cal l y i n thi s tabl e for your conveni ence.):
Block Name Description
Bernoul l i Random Bi nary Noi se
Gener ator
Gener ates Bernoul l i di str i buted
bi nary numbers
Bi nary Vector Noi se Gener ator Gener ates arbi trary l ength vectors
wi th random 0s and 1s
Err or-Rate Meter Cal cul ates and di spl ays symbol and
bi t err or rates
Eye-Patter n & Scatter Pl ot Gener ates eye-pattern di agrams
and scatter pl ots
Gaussi an Random Noi se Generator Gener ates average whi te Gaussi an
noi se (AWGN)
Poi sson Random I nteger Gener ator Gener ates Poi sson di stri buted
i ntegers i n a speci fi ed range
Rayl ei gh Noi se Gener ator Gener ates Rayl ei gh di stri buted
noi se
Ri ci an Random Noi se Generator Gener ates Ri ci an di str i buted noi se
Sampl e Ti me Eye-Pattern Di agr am
& Scatter Pl ot
Gener ates eye-pattern di agrams
and scatter pl ots
Sampl ed Read Fr om Wor kspace Reads data fr om a wor kspace fi l e at
speci fi ed sampl e ti mes
Tr i gger ed Read From Fi l e Reads a row of data from a fi l e when
tri gger ed
Tri ggered Read Fr om Wor kspace Reads a r ow of data from a work-
space vari abl e when tri ggered
Tri ggered Wr i te To Fi l e Wri tes a row of data to a fi l e when
tri gger ed
Sources and Sinks in C om m unication System s
6-7
Tri ggered Wr i te To Workspace Wri tes a row of data to a wor kspace
var i abl e when tri ggered
Uni for m Random I nteger Gener ator Gener ates uni forml y di stri buted
i ntegers i n a speci fi ed range
Uni for m Random Noi se Gener ator Gener ates uni forml y di stri buted
random noi se
Vector Pul se Gener ates a pul se tr ai n of vectors
Block Name Description
Uniform Random Noise Generator
6-8
Uni form Random Noi se Gener ator
6
Uni for m Random Noi se Generator
Catagory Noi se Gener ator
Location Sour ce/Si nk Subl i br ary
Description The Uni form Random Noi se Generator bl ock generates uni for ml y di str i buted
noi se. The output data of thi s bl ock i s uni for ml y di stri buted between speci fi ed
l ower and upper boundar i es. The upper bound must be l arger than the l ower
boundary.
You must speci fy the seed i n the si mul ati on. When the seed i s a fi xed number,
the gener ated noi se i s repeatabl e.
When the seed i s a vector , the output of the bl ock i s a vector wi th a l ength equal
to the l ength of the i nput seed. You can speci fy the boundari es of each el ement
of the output vector i ndi vi dual l y or, i f al l the el ements of the output vector ar e
i ndependent, i denti cal l y di stri buted (i .i .d)., you can use a scal ar for the
boundary. I f the boundari es are vector s, the vector l ength must equal the seed
vector l ength.
Dialog Box
Equivalent
M-function r and wi th contr ol of upper and l ower boundar i es
The l ower bound of the uni for m di str i buti on
noi se.
The upper bound of the uni for m di str i buti on
noi se. The vector si ze must be the same si ze as
the l ower bound of the output.
I ni ti al i ze the seed val ue. The vector si ze of the
seed sets the vector si ze of the output.
Gaussian Random Noise Generator
6-9
Gaussi an Random
Noi se Generator
Catagory Noi se Generator
Location Sour ce/Si nk Subl i br ary
Description The Gaussi an Random Noi se Generator bl ock generates whi te Gaussi an noi se.
You must speci fy the seed i n the si mul ati on. When the seed i s a fi xed number ,
the gener ated noi se i s repeatabl e. When the i nput seed i s a vector , the output
of the bl ock i s a vector of equal l ength.
The mean val ue and the covari ance matr i x can be ei ther scal ars or vectors.
When the mean val ue i s a scal ar , every el ement of the output si gnal shar es the
same mean val ue. Li kewi se, when the covari ance matr i x i s a scal ar, ever y
el ement of the output si gnal shares the same var i ance and the el ements are
uncor rel ated each other .
When the covari ance matri x i s a vector, the vector si ze must be the same as the
vector si ze for seed. I n thi s case, the covari ance matr i x i s a di agonal matr i x
wi th the di agonal el ement pr ovi ded i n the vector. Si nce the off-di agonal
el ements ar e zero, the output Gaussi an random vari abl es are uncorr el ated.
When the covar i ance matri x i s a squar e matri x, the off-di agonal el ements ar e
the corr el ati ons between pai r s of output Gaussi an r andom vari abl es. Note that
i n thi s case, the covar i ance matr i x must be a posi ti ve semi -defi ni te. The matr i x
must be N-by-N, wher e N i s the vector l ength of the seed.
Gaussian Random Noise Generator
6-10
Dialog Box
Equivalent
M-function r and wi th contr ol of upper and l ower boundari es
Speci fy the mean val ue of the r andom
var i abl e output.
Speci fy the covar i ance between the output
r andom var i abl es.
I ni ti al i ze the seed.
Uniform Random Integer Generator
6-11
Uni for m Ran dom
I nteger Gener ator
Catagory Noi se Generator
Location Sour ce/Si nk Subl i br ary
Description The Uni for m Random I nteger Generator bl ock generates uni forml y di stri buted
random i nteger s i n the r ange [0, M-1], where M i s the mul ti pl e number defi ned
i n the di al og box.
The output vector has the same l ength as the i nput seed. The output of the
bl ock i s a vector when the i nput seed i s a vector . The mul ti pl e number M can
be ei ther a scal ar or a vector . I f i t i s a scal ar , al l the output r andom var i abl es
ar e i .i .d. I f the mul ti pl e number i s a vector, i ts l ength must equal the l ength of
the seed; i n thi s case each output has i ts own output range.
Dialog Box
Equivalent
M-function
r andi nt
Speci fy the mul ti pl e number (s), whi ch must be a
posi ti ve i nteger . The i nteger s gener ated i n thi s
bl ock ar e i n the r ange [0, M-1].
I ni ti al i ze the seed. The vector l ength of the seed
sets the l ength of the output vector .
Poisson Random Integer Generator
6-12
Poi sson Random
I nteger Gener ator
Catagory Noi se Generator
Location Sour ce/Si nk Subl i brary
Description The Poi sson Random I nteger Generator bl ock generates random i ntegers wi th
a Poi sson di str i buti on.
The Poi sson pr obabi l i ty densi ty functi on i s
wher e x i s a non-negati ve i nteger and i s the Poi sson par ameter, whi ch must
be posi ti ve. The probabi l i ty densi ty functi on gi ves the pr obabi l i ty of the
appearance of a non-negati ve i nteger x i n the bl ock output sequence.
You can use the Poi sson r andom i nteger generator to gener ate noi se i n a bi nary
transmi ssi on channel . I n thi s case, the Poi sson par ameter shoul d be (much)
l ess than 1.
When the i nput seed i s a vector , the output of the bl ock i s a vector of equal
l ength.
Dialog Box
Equivalent
M-function poi s s r nd i n the Stati sti cs Tool box
y

x
x!
------e

=
Speci fy the Poi sson par ameter . When i t i s
a scal ar , ever y el ement i n the output vector
shar es the same . When i t i s a vector, the
vector l ength must be same as the seeds.
I ni ti al i ze the seed.
Binary Vector Noise Generator
6-13
Bi nar y Vector
Noi se Generator
Catagory Noi se Generator
Location Sour ce/Si nk Subl i br ary
Description The Bi nary Vector Noi se Gener ator outputs a l ength N bi nar y r andom vector,
where N i s the Vector length. The appearance of the 1s i n the output vector
i s uni forml y di stri buted.
You can speci fy the entr y for thi s bl ock as a vector, [p1, p2, p3,...pM], where p1
i s the probabi l i ty of a si ngl e 1 i n the bi nary vector , p2 i s the probabi l i ty of two
1s i n the bi nary vector, p3 i s the pr obabi l i ty of thr ee 1s i n the bi nary vector ,
and so on. The vector si ze M must be l ess than or equal to the bl ock output
l ength. Pl ease note that . The probabi l i ty of al l zer o vectors i s
. The mi ni mum vector si ze for thi s probabi l i ty vector i s 1 and the
maxi mum vector si ze for thi s vector i s the vector l ength speci fi ed i n Vector
length.
Thi s bl ock i s useful i n testi ng er ror -control codi ng al gori thms.
Dialog Box
p
i
i 1 =
m

1
1 p
i
i 1 =
m

Speci fy the vector l ength N.


Speci fy the pr obabi l i ty sequence. The sum of thi s
vector must be l ess than or equal to 1.
I ni ti al i ze the seed.
Rayleigh Noise Generator
6-14
Rayl ei gh
Noi se Gen erator
Catagory Noi se Generator
Location Sour ce/Si nk Subl i brary
Description The Rayl ei gh Noi se Gener ator bl ock gener ates Rayl ei gh di stri buted noi se.
The Rayl ei gh pr obabi l i ty densi ty functi on i s gi ven by
wher e i s known as the fadi ng envel ope of the Rayl ei gh di str i buti on.
The bl ock r equi r es you to speci fy the seeds i n the si mul ati on. When the seed i s
a fi xed number, the gener ated noi se i s r epeatabl e.
When the i nput seed i s a vector , the output of the bl ock i s a vector of equal
l ength. The Fading envelope can be ei ther a scal ar or a vector wi th i ts l ength
equal to the l ength of the Seed. When the fadi ng envel ope i s a scal ar , ever y
el ement of the output si gnal shar es the same fadi ng envel ope.
Dialog Box
Equivalent
M-function r ayl r nd i n the Stati sti cs Tool box
f x ( )
x

2
------e
x
2
2
2
---------
x 0
0 x 0 <

'

2
Speci fy as defi ned i n the Rayl ei gh pr obabi l i ty
densi ty functi on.
I ni ti al i ze the seed.

Rician Random Noise Generator


6-15
Ri ci an Random
Noi se Generator
Catagory Noi se Generator
Location Sour ce/Si nk Subl i br ary
Description The Ri ci an Random Noi se Generator bl ock gener ates Ri ci an di str i buted noi se.
The Ri ci an pr obabi l i ty densi ty functi on i s gi ven by
where i s the var i ance of the Gaussi an di stri buti on i n generati ng the Ri ci an
di str i buti on noi se. m
2
=m
I
2
+m
Q
2
, wher e m
I
and m
Q
are the mean val ues of the two
i ndependent Gaussi an components used i n constr ucti ng the Ri ci an
di str i buti on. Note that m and are not the mean val ue and the var i ance for
the Ri ci an di str i buted r andom number . Functi on i s the modi fi ed 0th
order Bessel functi on of the fi rst ki nd gi ven by:
You must speci fy the seeds i n the si mul ati on. When the seed i s a fi xed number,
the gener ated noi se i s repeatabl e.
When the seed i s a vector, the output of the bl ock i s a vector of equal l ength.
The mean val ue and the vari ance can be ei ther a scal ar or a vector; i n the
second case, the vector si ze must equal the seed vector si ze. When the mean
val ue (or vari ance) i s a scal ar, ever y el ement of the output si gnal shar es the
same mean val ue (or vari ance).
f x ( )
x

2
------I
0
mx

2
--------
,
_
e
x
2
m
2
+
2
2
-----------------
x 0
0 x 0 <

'

2
I
0
. ( )
I
0
y ( )
1
2
------ e
y t cos
t d

=
Rician Random Noise Generator
6-16
Dialog Box
Speci fy the Ri ci an K-factor , where
.
Speci fy the vari ance i s the var i abl e i n the
above Ri ci an pr obabi l i ty densi ty functi on.
Note that the mean and var i ance speci fi ed ar e
not those of the Ri ci an di stri buti on, but of the
under l yi ng Gaussi an r andom var i abl e.
K m
I
2
m
Q
2
+
,
_
2
2
( ) =

2
Bernoulli Random Binary Noise Generator
6-17
Bernou l l i Random Bi nary Noi se Gener ator
Category Noi se Generator
Location Sour ce/Si nk Subl i br ary
Description The Ber noul l i Random Bi nar y Noi se Generator bl ock generates Ber noul l i
random bi nar y number s. The output of thi s bl ock are bi nar y numbers. The
probabi l i ty of the zer o output i s p and the pr obabi l i ty of the one output i s 1-p.
Usi ng probabi l i ty notati on, we have P
X
(0) =p; P
X
(1) =1-p. The mean val ue of
the Bernoul l i di str i buti on i s 1-p. The var i ance of the Ber noul l i di stri buti on i s
p(1-p). The val ue of p must be no l ess than zer o and no l ar ger than one.
You must speci fy the zero occur ri ng pr obabi l i ty p i n the si mul ati on. When p
parameter i s a vector i n the entry, the output of thi s bl ock i s a vector wi th i ts
vector l ength the same as the parameter p. You need al so to speci fy the seed i n
the si mul ati on. The seed parameter can be a scal ar or a vector wi th the same
l ength as the vector p.
Dialog Box
Equivalent
M-function
x = r and( n, m) > p;
The probabi l i ty of outputi ng zer os. The output
si ze of thi s bl ock i s the same as the vector si ze of
thi s par ameter .
I ni ti al i ze the seed val ue. The seed can be a scal ar
or a vector wi th the same l ength as the vector i n
the fi r st entr ee of thi s bl ock.
Triggered Read From Workspace
6-18
Tr i gger ed Read
Fr om Wor kspace
Catagory Tri ggered Read
Location Sour ce/Si nk Subl i brary
Read a row of data fr om a wor kspace var i abl e at the r ai si ng edge of the tr i gger
si gnal .
Description Unl i ke the Si mul i nk Read From Wor kspace bl ock, The Tr i ggered Read From
Wor kspace bl ock reads the wor kspace var i abl e onl y at the rai si ng edge of the
i nput si gnal to thi s bl ock. Ther e ar e four par ameter entr i es to thi s bl ock:
Workspace variable, Threshold, Repeat flag, and Output value
before first trigger.
The Workspace variable i s a matri x wi th i ts col umn number bei ng the vector
si ze of the output of thi s bl ock. Before recei vi ng any tri ggered si gnal , thi s bl ock
outputs the val ue i n Output value before first trigger. When the tr i gger
si gnal cr osses from bel ow the Threshold val ue, the bl ock r eads a r ow of data
from the gi ven wor kspace var i abl e. When the bl ock r eaches the l ast r ow of the
workspace, i t returns to the fi r st row of the vari abl e or i t outputs zero
dependi ng on the Repeat flag speci fi cati on.
Dialog Box
Speci fy the wor kspace vari abl e name or the
contents of the var i abl e. The col umn si ze of thi s
par ameter sets the output vector s si ze.
Set the thr eshol d for the r i si ng edge of the
tri gger si gnal .
Speci fy whether to cycl e conti nuousl y thr ough
the workspace var i abl e or to output zer os after
end-of-fi l e (eof).
I ni ti al i ze the output val ue pr i or to the fi r st
tri gger .
Triggered Read From File
6-19
Tr i gger ed Read From Fi l e
Catagory Tri ggered Read
Location Sour ce/Si nk Subl i br ary
Description Unl i ke the Si mul i nk Read From Fi l e bl ock, the Tr i ggered Read From Fi l e bl ock
reads a recor d fr om a fi l e onl y at the rai si ng edge of the i nput tr i gger si gnal .
The fi l e can be an ASCI I text fi l e, a data fi l e, or a bi nary fi l e.
You must speci fy the vector l ength of the bl ock output. The bl ock reads the
gi ven l ength of recor d fr om the fi l e when a r ai si ng edge of the i nput tr i gger
si gnal i s detected. When the data type i s speci fi ed as ASCI I form, the output i s
an i nteger. The map between deci mal i nteger, hexadeci mal , and ASCI I
character i s shown i n the tabl e bel ow. When the data type i s other than ASCI I
text, thi s bl ock r eads a gi ven l ength of data from the fi l e.
Triggered Read From File
6-20
Decimal Hex
Code
Ascii
Char
Decimal Hex
Code
Ascii
Char
Decimal Hex
Code
Ascii
Char
Decimal Hex
Code
Ascii
Char
0 00 NUL 32 20 SP 64 40 @ 96 60 \
1 01 SOH 33 21 ! 65 41 A 97 61 a
2 02 STX 34 22 66 42 B 98 62 b
3 03 ETX 35 23 # 67 43 C 99 63 c
4 04 EOT 36 24 $ 68 44 D 100 64 d
5 05 ENQ 37 25 % 69 45 E 101 65 e
6 06 ACK 38 26 & 70 46 F 102 66 f
7 07 BEL 39 27 71 47 G 103 67 g
8 08 BS 40 28 ( 72 48 H 104 68 h
9 09 HT 41 29 ) 73 49 I 105 69 i
10 0A LF 42 2A * 74 4A J 106 6A j
11 0B VT 43 2B + 75 4B K 107 6B k
12 0C FF 44 2C , 76 4C L 108 6C l
13 0D CR 45 2D - 77 4D M 109 6D m
14 0E SO 46 2E . 78 4E N 110 6E n
15 0F SI 47 2F / 79 4F O 111 6F o
16 10 DLE 48 30 0 80 50 P 112 70 p
17 11 DC1 49 31 1 81 51 Q 113 71 q
18 12 DC2 50 32 2 82 52 R 114 72 r
19 13 DC3 51 33 3 83 53 S 115 73 s
20 14 DC4 52 34 4 84 54 T 116 74 t
21 15 NAK 53 35 5 85 55 U 117 75 u
22 16 SYN 54 36 6 86 56 V 118 76 v
23 17 ETB 55 37 7 87 57 W 119 77 w
24 18 CAN 56 38 8 88 58 X 120 78 x
25 19 EM 57 39 9 89 59 Y 121 79 y
26 1A SUB 58 3A : 90 5A Z 122 7A z
27 1B ESC 59 3B ; 91 5B [ 123 7B {
28 1C FS 60 3C < 92 5C \ 124 7C |
29 1D GS 61 3D = 93 5D ] 125 7D }
30 1E RS 62 3E > 94 5E ^ 126 7E ~
31 1F US 63 3F ? 95 5F _ 127 7F DEL
Triggered Read From File
6-21
When end-of-fi l e i s r eached, you can speci fy a r ecursi ve i ndex to contr ol the
output val ue. The bl ock goes back to read the very begi nni ng of the fi l e when
the r ecur si ve i ndex i s 1. The bl ock outputs zer os when the recur si ve i ndex i s
0.
You can al so speci fy how many tr i gger s the bl ock recei ves between fi l e r eads i n
the Number of trigger pulses between saved data parameter . Setti ng thi s
parameter to 0 forces the bl ock to read a r ecor d at every tri gger rai si ng edge.
The very fi r st recor d r ead fr om the fi l e al ways occurs after the fi r st rai si ng
edge.
Dialog Box
Speci fy the fi l ename, i ncl udi ng i ts extensi on.
Speci fy the data type as a str i ng var i abl e:
' as c i i ' , ' f l oat ' , ' i nt eger ' , or ' bi nar y' .
Contr ol how many tr i gger r ai si ng edges shoul d
be r ecei ved between fi l e reads.
Set the vector l ength of the fi l e output.
Speci fy whether to cycl e conti nuousl y thr ough
the wor kspace var i abl e or to output zer os after
eof.
Set the thr eshol d for the r ai si ng edge of the
tr i gger si gnal .
Sampled Read From Workspace
6-22
Sampl ed Read
Fr om Wor kspace
Catagory Sampl ed Read
Location Sour ce/Si nk Subl i brary
Description The Sampl ed Read From Wor kspace bl ock reads a r ow of data for a workspace
var i abl e at every sampl i ng poi nt. Thi s bl ock reads the wor kspace var i abl e onl y
at the exact sampl i ng poi nt of the sampl e ti me.
The workspace vari abl e i s a matr i x. The col umn number of the wor kspace
var i abl e i s the vector l ength of the bl ock output. When the si mul ati on ti me i s
l ess than the offset, thi s bl ock outputs the i ni ti al output val ue. When
si mul ati on ti me reaches the next sampl i ng poi nt, the bl ock r eads a r ow of data
from the gi ven wor kspace var i abl e. When the l ast row of the workspace i s
reached, the bl ock goes back to the fi r st r ow of the var i abl e or i t outputs zeros
dependi ng on the Repeat flag val ue.
Dialog Box
Speci fy the vari abl e name or the contents of the
var i abl e. The col umn si ze of thi s var i abl e sets the
vector l ength of the output.
The sampl i ng ti me of thi s bl ock. When thi s
par ameter i s a two-el ement vector , the second
el ement i s the offset val ue.
Speci fy whether to cycl e conti nuousl y thr ough
the workspace var i abl e or to output zer os after
end-of-fi l e (eof).
I ni ti al i ze the bl ock output. Thi s i s the val ue
output befor e the bl ock r eaches the offset val ue.
Vector Pulse
6-23
Vector Pul se
Catagory Pul se Si gnal Gener ator
Location Sour ce/Si nk Subl i br ary
Description The Vector Pul se bl ock gener ates a vector of pul se si gnal s. The sampl e
frequency of every el ement i n the vector pul se si gnal i s an i nteger mul ti pl i ed
by a common frequency F
0
. You can speci fy the offset for each pul se. The
advantage of usi ng the common frequency i s that thi s bl ock uses common
frequency i n the ti mi ng cal cul ati on, whi ch el i mi nates any r el ati ve ti mi ng err or
between the el ements outputted from the bl ock. Thi s makes the cal cul ati on
more accur ate.
The pul ses generated i n thi s bl ock have thei r pul se wi dth equal to exactl y hal f
of the pul se sampl i ng ti me. The pul se ampl i tude i s 1.
You must speci fy the Divider i n thi s bl ock. Thi s i s a vector of posi ti ve i nteger s
that set the sampl e ti mes for the i ndi vi dual output pul ses. Each el ement of the
vector i s di vi ded by the sampl e ti me to produce the i ndi vi dual sampl e ti mes. I f
t
s
i s the sampl e ti me and [d1, d2, ..., dn] i s the di vi der vector, then the
i ndi vi dual pul se sampl e ti mes ar e d1/t
s
, d2/t
s
, ... dn/t
s
. I n other words, the
frequenci es for the i ndi vi dual pul ses ar e t
s
/d1, t
s
/d2, ..., t
s
/dn. The l ength of the
Divider al so sets the l ength of the output vector .
Dialog Box
Speci fy the sampl e ti me. The i nver se of the
sampl e ti me i s the common fr equency.
A vector of posi ti ve i nteger s.The output vector
l ength equal s the l ength of the di vi der .
The offset for the begi nni ng of the pul ses. The
el ements of thi s vector must be non-negati ve r eal
number s.
Vector Pulse
6-24
Example Thi s exampl e assumes that the three parameter entri es ar e as fol l ows. The
sample time i s Fo, the Divider is [2 3], and the Offset i s [offset, 0]. The output
of thi s bl ock i s shown bel owFi gur e 6-3:. Thi s fi gur e i s dr awn wi th the
assumpti on that offset < 1/Fo/2.
Figure 6-3: Two-Element Vector Output
o
f
f
s
e
t
o
f
f
s
e
t
1/Fo 1/2/Fo 1/3/Fo 2/3/Fo
Element1
Element2
Time
Triggered Write To Workspace
6-25
Tr i gger ed Wr i te
To Wor kspace
Catagory Tri ggered Wr i te
Location Sour ce/Si nk Subl i br ary
Description Unl i ke the Si mul i nk Wr i te To Wor kspace bl ock, the Tr i gger ed Wri te To
Workspace bl ock wri tes to a wor kspace var i abl e onl y at the r ai si ng edge of the
tr i gger si gnal . There ar e si x entri es to thi s bl ock: Workspace variable; Data
type; Number of trigger pulses between save data; Maximum row number;
Section to keep when overflow; and Threshold.
The fi r st i nput por t accepts the message si gnal . The second i nput port takes the
tr i gger si gnal . The message si gnal to the fi r st i nput por t can be ei ther a scal ar
or a vector . The tri gger si gnal to the second i nput por t must be a scal ar.
The saved workspace vari abl e i s a col umn vector when the fi r st port has a
scal ar i nput. I t i s a matr i x when the fi rst port has a vector i nput. The fi rst
el ement of the i nput si gnal vector i s saved i n the fi rst col umn; the second
el ement of the i nput si gnal vector i s saved i n the second col umn, and so on.
The bl ock saves the fi rst r ecor d at the fi rst rai si ng edge of the tr i gger si gnal .
The data can be saved as str i ng or data. The maxi mum r ow of the output
var i abl e i s l i mi ted by a pr e-defi ned number. Thi s number cannot be changed
dur i ng si mul ati on. After the l i mi t i s r eached, the bl ock keeps the fi rst par t of
the si mul ati on data or the l atest si mul ati on data dependi ng on the entr y i nto
Section to keep when overflow.
You can speci fy how many tri ggers the bl ock recei ves between fi l e reads i n the
Number of trigger pulses between save data par ameter. Setti ng thi s
parameter to 0 forces the bl ock to read a r ecor d at every tri gger rai si ng edge.
The very fi r st recor d r ead fr om the fi l e al ways occurs after the fi r st rai si ng
edge.
Triggered Write To Workspace
6-26
Dialog Box
A str i ng var i abl e. You must i ncl ude the extensi on
i f there i s one.
Choose one of two for mats: ' as ci i ' or 'dat a' .
' as c i i ' for ces a save i n the asci i for mat, ' dat a'
i n the MATLAB data format.
Contr ol how many tr i gger rai si ng edges shoul d
be r ecei ved between fi l e reads.
Li mi t the number of col umns of data that can be
saved.
I f the var i abl e r eaches i ts maxi mum r ecor d
number , sel ect 0 to keep the fi r st par t of the
si mul ati on r ecor d and 0 to keep the l ast par t.
Set the thr eshol d for the r ai si ng edge of the
tri gger si gnal .
Triggered Write To File
6-27
Tri gger ed Wri te
To Fi l e
Catagory Tri ggered Wr i te
Location Sour ce/Si nk Subl i br ary
Description Unl i ke the Si mul i nk Wr i te To Fi l e bl ock, the Tri gger Wri te To Fi l e bl ock wr i tes
a r ecord to a fi l e onl y at the r ai si ng edge of the i nput tr i gger si gnal . The fi l e can
be an ASCI I text fi l e or a data fi l e.
The fi r st i nput por t accepts the message i nput si gnal . The second i nput port
takes the tr i gger si gnal , whi ch must be a scal ar. The bl ock wri tes to the fi l e at
the rai si ng edge of the i nput tr i gger si gnal .
When the data type i s speci fi ed as ASCI I for m, thi s bl ock conver ts the i nput
data i nto ASCI I characters by usi ng the map gi ven i n the Tr i gger ed Read From
Fi l e bl ock. When the data type i s a type other than ASCI I text, thi s bl ock
di rectl y wr i tes the data i nto the fi l e. Each tr i gger ed r ecord i s wr i tten to a
separ ate l i ne i n the fi l e.
You can al so speci fy how many tr i gger s the bl ock recei ves between fi l e r eads i n
the Number of trigger pulses between saved data parameter . Setti ng thi s
parameter to 0 forces the bl ock to read a r ecor d at every tri gger rai si ng edge.
The very fi r st recor d r ead fr om the fi l e al ways occurs after the fi r st rai si ng
edge.
Dialog Box
Speci fy the fi l ename, i ncl udi ng i ts extensi on.
Speci fy the data type as a str i ng var i abl e:
' as c i i ' , ' f l oat ' , ' i nt eger ' , or ' bi nar y' .
Contr ol how many tr i gger r ai si ng edges shoul d
be r ecei ved between fi l e reads.
Set the thr eshol d for the r ai si ng edge of the
tr i gger si gnal .
Eye-Pattern & Scatter Plot
6-28
Eye-Pattern &
Scatter Pl ot
Catagory Pl otti ng
Location Sour ce/Si nk Subl i brary
Description The Eye-Pattern & Scatter Pl ot bl ock pl ots eye-patter n pl ots, scatter pl ots or
x-y pl ots dependi ng on the par ameter speci fi cati on.
Eye-pattern plot
An eye-pattern pl ot i s a si mpl e and conveni ent tool to study the effects of
i nter -symbol i nterference and other channel i mpai rments for di gi tal
transmi ssi on. The recei ved si gnal i s pl otted agai nst ti me, but when the x-axi s
ti me l i mi t i s reached, the si gnal goes back to the begi nni ng of the ti me poi nt.
Thi s produces an overl ai d set of pl ots. Typi cal l y, the ti me r ange i s an i nteger
mul ti pl e of the symbol i nter val .
The offset ti me (or deci si on poi nt) i s pl otted as a ver ti cal l i ne. General l y thi s
shoul d occur when the eye of the pl ot i s open to i ts wi dest poi nt. Thi s i s the
poi nt when the Scatter pl ot sampl es the si gnal , whi ch i s known as the deci si on
poi nt.
Scatter plot
Scatter pl ots r ecord the si gnal val ue at a gi ven deci si on poi nt. When the i nput
si gnal i s a two-di mensi onal vector , the scatter pl ot i s a two-di mensi onal pl ot
wi th the x-axi s as the fi rst i nput vector el ement and the y-axi s as the second
i nput vector el ement. The two-di mensi onal pl ot i s wi del y used i n the QAM
appl i cati on. I n the case of an i nput vector that i s not a l ength two vector, the
pl ot i s a one-di mensi onal pl ot.
x-y plot
x-y pl ot i s val i d onl y when the i nput message si gnal i s a l ength two vector . The
si mul ati on wi l l be termi nated i f the i nput si gnal has a di mensi on other than
l ength two.
The above menti oned pl ots can be pl otted i n a same wi ndow. You can set up the
parameter to acti vate a pl ot or el i mi nate a pl ot before the si mul ati on. Pl ease
note that the eye-patter n pl ot and the x-y pl ot are pl ots r ecor di ng the
trajector i es of the message si gnal . The pl ot may take a l ong ti me to dr aw these
trajector i es at ever y si mul ati on poi nt. I n contrast, the scatter pl ot pl ots onl y
the poi nt when the deci si on i s made. The si mul ati on i s much faster when onl y
scatter pl ot i s acti vated.
Eye-Pattern & Scatter Plot
6-29
The fi r st i nput por t accepts the message si gnal . The second i nput port takes the
deci si on si gnal . The rai si ng edge of the deci si on si gnal i s the speci fi ed ti mi ng
for the deci si on poi nt, whi ch tr i gger s the scatter pl ot. There i s a ver ti cal l i ne i n
the eye-pattern pl ot, whi ch i ndi cates the ti me when the deci si on i s made. The
deci si on pul se i s a scal ar i nput si gnal .
The fi gur e bel ow i s a snap shot of the pl ot cr eated by usi ng thi s eye-patter n and
scatter pl ot.
Figure 6-4: Eye-pattern, Scatter and x-y plots
You must speci fy the x-axi s of the eye-pattern pl ot usi ng the Eye-pattern plot
time frame parameter . Typi cal l y, the ti me fr ame shoul d be an i nteger
mul ti pl i ed by the symbol i nter val . When thi s entr y i s a two-el ement vector , the
second el ement i s the of f s e t ; the defaul t val ue of of f s et i s 0. The pl ot takes
al l pl ots i nto the ti me frame [ of f s e t , of f s e t +t i me_f r ame] . Al l si gnal s at ti me
t ar e pl otted at the ti me poi nt
r em( t - of f s e t , t i me _f r am) i n t he e ye - pat t er n pl ot .
0 0.05 0.1 0.15 0.2
1.5
1
0.5
0
0.5
1
1.5
1 0 1
1.5
1
0.5
0
0.5
1
1.5
1 0 1
1.5
1
0.5
0
0.5
1
1.5
Eye-Pattern & Scatter Plot
6-30
The Line type for eye-pattern diagram parameter speci fi es the col or and the
l i ne type or pl ot symbol s for eye-pattern pl ot. A sl ash (/) i s used to separ ate l i ne
types of di fferent el ements i n the pl ot vector . You can choose the col or and l i ne
type code fr om fol l owi ng tabl e
When the l i ne type i s set to 0, the eye-pattern pl ot i s el i mi nated.
Pl ease note that the x-y pl ot can onl y be used when the i nput message si gnal
i s a two-el ement vector .
Color
Character
Meaning Marker-type
Character
Meaning Line-type
Character
Meaning
y yel l ow . poi nt - sol i d
m magenta o ci r cl e : dotted
c cyan x x-mar k - . dashdot
r r ed + pl us - - dashed
g green * star
b bl ue s square
w whi te d di amond
k bl ack v tri angl e
(down)
^ tri angl e (up)
< tri angl e (l eft)
> tri angl e
(ri ght)
p pentagram
h hexagram
Eye-Pattern & Scatter Plot
6-31
Dialog Box
Equivalent
M-function
ey e s c at
Speci fy the x-axi s of the eye-patter n pl ot. When
thi s entr y i s a two-el ement vector, the second
el ement i s the offset val ue.
A two-el ement vector . The fi r st el ement i s the
l ower bound of the i nput si gnal , the second the
upper bound
An i nteger that speci fi es the number of saved
tr ace pl ots.
Speci fy the col or , l i ne type, and/or pl ot symbol s
for the eye-patter n pl ot.
The col or , l i ne type, and/or pl ot symbol s for the
scatter pl ot and x-y pl ot respecti vel y. A 0 entr y
suppr esses the pl ot enti r el y.
Sample Time Eye-Pattern Diagram & Scatter Plot
6-32
Sampl e Ti me Eye-Patter n Di agram & Scatter Pl ot
Category Pl otti ng
Location Sour ce/Si nk Subl i brary
Description The Sampl e-ti me Eye-Patter n Di agram & Scatter Pl ot bl ock pl ots eye-pattern
pl ot, and/or scatter pl ot based on the parameter speci fi cati on.
You shoul d read the r efer ence page for the Eye-Patter n Di agram & Scatter Pl ot
bl ock for the detai l ed descri pti on of the eye-pattern pl ot and scatter pl ot.
Di fferent from the Eye-Pattern & Scatter Pl ot bl ock, thi s bl ock does not provi de
the x-y pl ot. Thi s bl ock does not have a dedi cated por t for the deci si on ti mi ng
si gnal . The deci si on ti mi ng i s set i nsi de the parameter i nstead.
Sample Time Eye-Pattern Diagram & Scatter Plot
6-33
You can speci fy the col or code and l i ne type/marker type i n thi s bl ock. A sl ash
(/) i s used to separate type code i n the pl ot parameter . You can choose the col or
code and l i ne type or marker type code fr om the fol l owi ng tabl e.
I f you l i ke to el i mi nate the eye-patter n pl ot or the scatter pl ot, si mpl y set the
l i ne type to be the number 0.
Color
Character
Meaning Marker-type
Character
Meaning Line-type
Character
Meaning
y yel l ow . poi nt - sol i d
m magenta o ci r cl e : dotted
c cyan x x-mar k - . dashdot
r r ed + pl us - - dashed
g green * star
b bl ue s square
w whi te d di amond
k bl ack v tr i angl e
(down)
^ tr i angl e (up)
< tr i angl e (l eft)
> tr i angl e
(ri ght)
p pentagram
h hexagram
Sample Time Eye-Pattern Diagram & Scatter Plot
6-34
Dialog Box
Equivalent
M-function
ey es cat
A thr ee el ements vector . The fi r st el ement i s
symbol i nter val , whi ch i s the eye-patter n
di agr am x-axi s l ength. I t i s al so the update
i nter val for the scatter pl ot. The second el ement
i s the offset for the eye-patter n pl ot. The thi r d
el ement i s the deci si on poi nt offset. I t i s al so the
offset for the update of the scatter pl ot. The uni t
for al l three el ements i s i n second.
A two-el ement vector . The fi r st el ement i s the
l ower bound of the i nput si gnal , the second the
upper bound.
Speci fy the number of saved tr ace pl ots.
Speci fy the col or , mar ker or l i ne type for the
eye-patter n pl ot.
Speci fy the col or , mar ker or l i ne type symbol s for
the scatter pl ot.
The sampl e ti me for eye-pattern di agr am pl ot
update.
Error Rate Meter
6-35
Er ror Rate
Meter
Catagory Symbol -Err or Di spl ay
Location Sour ce/Si nk Subl i br ary
Description The Err or Rate Meter bl ock cal cul ates and di spl ays the symbol -er ror and
bi t-er ror rates.
One of the major tasks for communi cati on system si mul ati on i s to esti mate the
symbol -er ror r ate and the bi t-err or rate of a tr ansmi tti ng system. The Er ror
Rate Meter bl ock provi des an er ror-r ate computati on and di spl ay duri ng the
communi cati on system si mul ati on.
The fi r st i nput por t takes the i nput fr om the tr ansmi tti ng si de. The si gnal to
the fi rst i nput por t must be a scal ar. The second i nput port takes the i nput fr om
the recei vers. The si gnal to the second por t can be a scal ar or a vector. I n the
vector case, the r ecei ved si gnal l i sted i n the meter di spl ay i s named recei ver1,
recei ver2, ... by the order of the posi ti on of the si gnal i n the vector . The bl ock
counts and then di spl ays the number of symbol s transferr ed and the number
of bi ts transferr ed. I t al so makes a compari son between the sendi ng di gi tal
si gnal and the r ecei ved di gi tal si gnal at a gi ven sampl e-ti me poi nt.
The bl ock can adjust the ti me del ay from the sendi ng si de to the r ecei vi ng si de.
I t assumes that the del ay i s the same for ever y r ecei ver when the i nput for the
recei ver i s a vector . When a di fference i s found between the sent di gi t and the
recei ved di gi t, the meter r egi ster s an err or . At the same ti me, the bi t er ror i s
esti mated. The symbol -er ror rate i s the total number of symbol err or s di vi ded
by the total number of symbol s tr ansfer red. The bi t-err or rate i s the total
number of bi t err or di vi ded by the total number of bi ts transferr ed.
A posi ti ve i nteger i n the Number of digits on display entry forces the meter
to di spl ay the exact number of rows as speci fi ed. The di spl ay swi tches the col or
between bl ue and green. When a r ecei ved di gi t di ffers from the sent data, the
di spl ay on the r ecei ver s l i ne has a r ed col or on di spl ay. A 0 or negati ve number
i n the Number of digits on display entr y tel l s the meter not to di spl ay the
tr ansfer red di gi tal si gnal .
Error Rate Meter
6-36
Dialog Box
Example Thi s exampl e shows a snap shot of the fi gur e gener ated by the Err or Rate
Meter bl ock dur i ng a si mul ati on. I n the si mul ati on, the i nput si gnal to the
second i nput por t i s a two-el ement vector si gnal . Ther e ar e four bi ts i n each
transferr ed symbol . There ar e 20 l i nes on di spl ay, whi ch l i st the most r ecent 20
di gi ts i n the transmi tti ng si de and the r ecei vi ng si de. The err or r ate as wel l as
the sent and r ecei ved di gi t ar e shown i n the fi gure.
Speci fy the number of bi ts per tr ansfer r ed
symbol .
Speci fy how many di gi ts the bl ock compar es
between the sent and r ecei ved si gnal s.
A scal ar esti mate of the del ay between tr ansmi s-
si on and r ecei pt of data. The bl ock uses thi s
par ameter to adjust the er r or esti mate.
The sampl i ng ti me for di gi t di spl ay, er ror -r ate
cal cul ati on, and err or -r ate di spl ay. When thi s
par ameter i s a two-el ement vector , the second
el ement i s the offset val ue.
Error Rate Meter
6-37
Figure 6-5: Figure Generated by Error Rate Meter in a Simulation
Equivalent
M-function s y mer r and bi t e r r
6-38
6
Source Coding
Sour ce codi ng i n communi cati on systems converts ar bi tr ary r eal -wor l d
i nfor mati on to an acceptabl e representati on i n communi cati on systems. Thi s
secti on provi des some basi c techni ques as exampl es of sol vi ng the sour ce
codi ng pr obl ems usi ng Si mul i nk and MATLAB. Thi s tool box i ncl udes the source
codi ng techni ques of si gnal quanti zati on and di ffer enti al pul se code
modul ati on (DPCM).
Thi s secti on al so i ncl udes compander techni ques. Compander i s the name for
the combi nati on of compressor and expander . Data compressi on i s i mpor tant
for transformi ng a si gnal s wi th di ffer ent power l evel transfor mati on.
Thi s fi gure shows the Sour ce Codi ng Subl i br ary:
Figure 6-6: Source Coding Sublibrary
6-39
Source Coding Reference Table
Thi s tabl e l i sts the Si mul i nk bl ocks i n the Source Codi ng Subl i brar y. (They are
l i sted al phabeti cal l y i n thi s tabl e for your conveni ence.):
Block Name Description
A-Law Compr essor Compresses data usi ng an A-l aw
compander
A-Law Expander Recover s compressed data usi ng an
A-l aw compander
DPCM Decode Recover s DPCM quanti zed si gnal s
DPCM Encode Quanti zed i nput data si gnal s
-Law Compr essor Compresses data usi ng a -l aw
compander
-Law Expander Recover s compressed data usi ng a
-l aw compander
Quanti zati on Decode Recover s si gnal s quanti zed by the
Si gnal Quanti zer or the Tr i gger ed
Si gnal Quanti zer bl ock
Si gnal Quanti zer Quanti zes an i nput si gnal
Tri ggered Si gnal Quanti zer Quanti zes an i nput si gnal when
tr i gger ed
Signal Quantizer
6-40
Si gnal Quanti zer
6
Catagory Si gnal Quanti zati on
Location Sour ce Codi ng Subl i br ar y
Description The Si gnal Quanti zer bl ock encodes a message si gnal usi ng scal ar
quanti zati on. The bl ock uses the fi ni te l ength of a di gi t to represent an anal og
si gnal . Pl ease r efer to chapter 3, the Tutorial, for the gener al pri nci pl es of
quanti zati on computati on. Note that you may l ose computati on accuracy i n the
quanti zati on processi ng.
I n quanti zati on, the major parameter s are Quantization partition and
Quantization codebook. Quantization partition i s a stri ct ascendi ng
ordered vector , whi ch contai ns the par ti ti on poi nts used i n di vi di ng up the
i nput data. Quantization codebook i s a quanti zati on val ue vector wi th l ength
equal to the (l ength + 1) of the Quantization partition. I f the i nput val ue i s
l ess than the i th el ement of Quantization partition (and greater than (i -1)th
el ement, i f any), the quanti zati on val ue equal s to the i th el ement i n the
Quantization codebook.
6-41
The fi gur e bel ow shows the quanti zati on process:
Figure 6-7: Quantization
Thi s bl ock has one i nput port and three output ports. The i nput port takes the
anal og si gnal . The thr ee output por ts output, fr om top to bottom, the
quanti zati on i ndexFi gur e 6-7:, the di stor ti on val ue, and the quanti zati on
val ueFi gur e 6-7:. The di stor ti on i s a measur ement of the quanti zati on err or.
The vector l engths of al l thr ee outputs ar e equal to the vector l ength of the
i nput. The quanti zati on bl ock can accept a vector i nput. When the i nput i s a
vector, each output por t outputs a vector wi th the vector l ength equal to the
i nput vector l ength. The bl ock pr ocesses each el ement of the vector
i ndependentl y; i t perfor ms the quanti zati on at the sampl e ti me.
Partition
Partition_index
Partition_index
Quantization value
- p
1
p
3
p
4
p
N-1
p
2
s = 0
1
s = N-1
N
s = 3
4
s = 2
3
s = 1
2
0 1 2
N-1
c
2
c
1
c
3
c
N
Block_input
6-42
You can use the functi on l l oyds to trai n the avai l abl e data to obtai n the
expected parti ti on and codebook vectors.
Dialog Box
Characteristics No. of I nputs/Outputs 1/3
Vector i zed I nputs/ Outputs Yes/Yes
I nput Vector Wi dth Auto
Output Vector Wi dth Same as the i nput vector wi dth
Scal ar Expansi on N/A
Ti me Base Di scr ete ti me
States N/A
Di r ect feedthrough Yes
Pair Block Quanti zati on Decode
Equivalent
M-function quant i z for quanti zati on computati on
l l oy ds for par ti ti on and codebook trai ni ng usi ng the avai l abl e data
A l ength N vector , where N i s the number of
symbol s i n the symbol set. Thi s must be a str i ctl y
ascendi ng or der ed vector.
A l ength N-1 str i ctl y ascendi ng order ed vector .
Speci fy the l ength of the i nput si gnal .
Speci fy the sampl e ti me. When thi s par ameter i s
a two-el ement vector , the second el ement i s the
offset val ue.
Triggered Signal Quantizer
6-43
Tr i gger ed Si gnal Quanti zer
Catagory Si gnal Quanti zati on
Location Sour ce Codi ng Subl i br ary
Description The Tr i gger Si gnal Quanti zer bl ock performs quanti zati on when a tri gger
si gnal occur s. Thi s bl ock i s si mi l ar to the Si gnal Quanti zer bl ock except that
the quanti zati on processi ng i s control l ed by the second i nput port of thi s bl ock,
the tri gger si gnal . Thi s bl ock r enews i ts output when the scal ar si gnal fr om the
second i nput por t i s a nonzero si gnal . Pl ease r efer to the Si gnal Quanti zer bl ock
for a di scussi on of scal ar quanti zati on.
Thi s bl ock has two i nput ports and thr ee output por ts. The quanti zer bl ock
takes message i nput fr om the fi r st i nput por t. I t takes the tri gger si gnal fr om
the second i nput port. The three output ports output quanti zati on i ndex,
quanti zati on val ue, and quanti zati on di storti on. When the message i nput i s a
vector, the thr ee outputs ar e al so vector s wi th thei r vector l ength equal to the
i nput vector l ength. Each el ement i n the vector i s i ndependentl y pr ocessed.
Dialog Box
A l ength N vector, wher e N i s the number of
parti ti on val ues. Thi s must be a str i ctl y
ascendi ng or der ed vector .
A l ength N-1 stri ctl y ascendi ng or der ed vector .
Speci fy the l ength of the i nput si gnal .
Triggered Signal Quantizer
6-44
Characteristics No. of I nput/Outputs 2/3
Vector i zed No. 1 I nput Yes
Vector i zed No. 2 I nput No
Vector i zed Outputs Yes
No. 1 I nput Vector Wi dth Auto
Output Vector Wi dth Same as the i nput vector wi dth
Scal ar Expansi on N/A
Ti me Base Tri ggered
States N/A
Di r ect feedthrough Yes
Pair Block Quanti zati on Decode
Equivalent
M-function
quant i z
Quantization Decode
6-45
Quanti zati on Decode
Catagory Decodi ng
Location Sour ce Codi ng Subl i br ary
Description The Quanti zati on Decode bl ock recover s a message fr om a quanti zed si gnal by
fi ndi ng the quanti zati on val ue fr om quanti zati on i ndex. The i nput of thi s bl ock
i s the quanti zati on i ndex, whi ch contai ns the el ements i n S = [s
1
, s
2
, ... s
N
] = [0,
1, ... N-1]. The output of thi s bl ock i s quanti zed val ue, whi ch contai ns the
el ements i n C = [c
1
, c
2
, ..., c
N
]. The vector S and C are i ntr oduced i n the Si gnal
Quanti zer bl ock.
Thi s i mpl ementati on of thi s bl ock uses a l ook-up tabl e.
Dialog Box
Characteristics No. of I nputs/ Outputs 1/1
Vector i zed I nputs/ Outputs Yes/Yes
I nput Vector Wi dth Auto
Scal ar Expansi on N/A
Ti me Base Auto
States N/A
Di r ect feedthr ough Yes
Pair Blocks Si gnal Quanti zer, Tri gger ed Si gnal Quanti zer
Equivalent
M-function There i s no quanti zati on decode functi on i n thi s tool box. For decode
computati on, use the command:
y = c odebook( quant i z _i nde x + 1) ;
A l ength N vector, wher e N+1 i s the number of
parti ti ons. The i th el ement i s the quanti zati on
output for the (i -1)th quanti zati on i ndex. The
defaul t val ue for the codebook i s
[-0.825 -0.5 0 0.5 0.825].
DPCM Encode
6-46
DPCM Encode
Catagory Encodi ng
Location Sour ce Codi ng Subl i br ary
Description The DPCM (Di ffer enti al Pul se Code Modul ati on) Encode bl ock quanti zes an
i nput si gnal . Thi s method uses a pr edi ctor to esti mate the possi bl e val ue of the
si gnal at the next step based on the past i nfor mati on i nto the system. The
predi cti ve er ror i s quanti zed.
Thi s method i s speci al l y useful to quanti ze a si gnal wi th a predi ctabl e val ue.
Thi s bl ock uses the Si gnal Quanti zer bl ock. Refer to the Si gnal
Quanti zer bl ock for a di scussi on of the codebook and par ti ti on concepts.
The pr edi ctor i n thi s tool box i s assumed to be a l i near predi ctor. You can use
the functi on dpc mopt to tr ai n the par ameters used i n thi s bl ock: Predictor
numerator, Predictor denominator, Quantization partition, and
Quantization codebook. You must i nput the numerator and denomi nator of
the predi ctors transfer functi on, but the output of dpc mopt pr ovi des onl y the
numer ator . I n most DPCM appl i cati ons, the denomi nator of predi ctor tr ansfer
functi on i s 1, whi ch means that the predi ctor i s a FI R fi l ter.
When the numerator of the predi ctor transfer functi on i s a fi rst-order
pol ynomi al wi th the fi rst el ement (zer o-or der el ement) equal to one, the DPCM
i s a del ta modul ati on.
DPCM Encode
6-47
Dialog Box
Characteristics No. of I nputs 1/2
Vector i zed I nputs/ Outputs No/No
Ti me Base Di scr ete ti me
States N/A
Di r ect feedthr ough Yes
Pair Block DPCM Decode
Equivalent
M-function
dpc me nc o
A vector contai ni ng the coeffi ci ents i n ascendi ng
order of the numer ator of the pr edi ctor tr ansfer
functi on.
A vector contai ni ng the coeffi ci ents i n ascendi ng
order of the denomi nator of the pr edi ctor tr ansfer
functi on. Usual l y thi s par ameter i s set to 1.
A l ength N vector, wher e N+1 i s the number of
parti ti on val ues. Thi s must be a str i ctl y
ascendi ng or der ed vector .
A l ength N+1 str i ctl y ascendi ng or dered vector
that speci fi es the output val ues assi gned to each
parti ti on.
The cal cul ati on sampl e ti me. When thi s par am-
eter i s a two-el ement vector , the second el ement
i s the offset val ue.
DPCM Decode
6-48
DPCM Decode
Catagory Decodi ng
Location Sour ce Codi ng Subl i br ary
Description The DPCM (Di ffer enti al pul se code modul ati on) Decode bl ock r ecover s a
quanti zed si gnal . Thi s bl ock i nputs the DPCM encoded i ndex si gnal and
outputs the recover ed si gnal to the fi rst output port and the pr edi cti ve er ror to
the second output por t.
Dialog Box
Characteristics No. of I nputs 1/2
Vector i zed I nputs/ Outputs No/No
Scal ar Expansi on N/A
Ti me Base Di scr ete ti me
States N/A
Di r ect feedthrough Yes
Pair Block DPCM Encode
Equivalent
M-function
dpcmde c
Match these par ameter s to the ones used i n the
cor r espondi ng DPCM Encode bl ock.
The cal cul ati on sampl e ti me. When thi s par am-
eter i s a two-el ement vector , the second el ement
i s the offset val ue.
A-Law Compressor
6-49
A-Law Compr essor
Catagory Data Compr essi on
Location Sour ce Codi ng Subl i br ary
Description The A-Law Compr essi on bl ock per forms data compr essi on. The formul a for the
-l aw compr essor i s
The parameter s to be speci fi ed i n the -l aw compr essor are the A val ue and the
peak magni tude V. The most commonl y used A val ue i n pr acti ce i s 87.6.
Dialog Box
Characteristics No. of I nputs/Output 1/1
Vector i zed I nputs/ Outputs Yes/Yes
Scal ar Expansi on N/A
Ti me Base Auto
States N/A
Di r ect feedthr ough Yes
Pair Block A-Law Expander
Equivalent
M-function
compand
y
A x
1 A l og +
---------------------- x ( ) sgn
V 1 A x V l og + ( )
1 A l og +
---------------------------------------------- x ( ) sgn
for 0 x A V
for A V x V <

'

=
The par ameter A i n the A-l aw compressor
equati on.
Speci fy the peak val ue for the i nput si gnal . Thi s
i s the parameter V i n the above equati on, and the
output peak magni tude as wel l .
A-Law Expander
6-50
A-Law Expander
Catagory Data Decompressi on
Location Sour ce Codi ng Subl i br ary
Description The A-Law Expander bl ock recovers compr essed data. The for mul a for the
-l aw expander i s the i nver se of the compressor functi on:
You must speci fy the A val ue and the peak magni tude V.
Dialog Box
Characteristics No. of I nputs/Output 1/1
Vector i zed I nputs/ Outputs Yes/Yes
Scal ar Expansi on N/A
Ti me Base Auto
States N/A
Di r ect feedthrough Yes
Pair Block A-Law Compr essor
Equivalent
M-function
compand
x
y
1 A l og +
A
---------------------- y ( ) sgn
e
y 1 A l og + ( ) V 1 V
A
---- y ( ) sgn
for 0 y
V
1 A l og +
----------------------
for
V
1 A l og +
---------------------- y V <

'

=
Match these par ameter s to the ones used i n the
cor r espondi ng A-Law Compressor bl ock.
-Law Compressor
6-51
-Law Compressor
Catagory Data Compr essi on
Location Sour ce Codi ng Subl i br ary
Description The -Law Compressor bl ock perfor ms data compr essi on. The formul a for the
-l aw compr essor i s:
The parameter s to be speci fi ed i n the -l aw compr essor are val ue and the
peak magni tude V. The most commonl y used val ue i n practi ce i s 255.
Thi s bl ock has one i nput and one output. I t takes the x val ue and outputs the
y val ue descri bed i n the above equati on.
Dialog Box
Characteristics No. of I nputs/Output 1/1
Vector i zed I nputs/ Outputs Yes/Yes
Scal ar Expansi on N/A
Ti me Base Auto
States N/A
Di r ect feedthr ough Yes
Pair Block -Law Expander
Equivalent
M-function
compand
y
V 1 x V + ( ) l og
1 + ( ) l og
--------------------------------------------- x ( ) sgn =
The par ameter i n the -l aw compr essor
equati on. The defaul t val ue i s 255.
Speci fy the peak magni tude of the i nput si gnal .
Thi s par ameter i s V i n the above equati on and
the output peak magni tude as wel l .
-Law Expander
6-52
-L aw Expander
Catagory Data Compr essi on
Location Sour ce Codi ng Subl i br ary
Description The -Law Expander bl ock recovers a si gnal from compressed data. The
for mul a for the -l aw expander i s the i nver se of the compr essor functi on:
Same as the -l aw compressor, the par ameters to be speci fi ed i n the -l aw
compressor are val ue and the peak magni tude V.
Thi s bl ock takes y as the i nput and outputs x.
Dialog Box
Characteristics No. of I nputs/Output 1/1
Vector i zed I nputs/ Outputs Yes/Yes
Scal ar Expansi on N/A
Ti me Base Auto
States N/A
Di r ect feedthrough Yes
Pair Block -Law Compr essor
Equivalent
M-function
compand
x
V

---- e
y 1 + ( ) l og V
1 + ( ) y ( ) sgn =
Match these par ameter s to the ones used i n the
cor r espondi ng -Law Compr essor bl ock.
6-53
6
Error-Control Coding
The goal of err or-control codi ng techni ques i s to r educe the tr ansmi ssi on er ror
i n a communi cati on system. Er ror-contr ol codi ng i s an ar ea of very acti ve
resear ch i n the communi cati ons fi el d. Thi s tool box supports the most
commonl y used er ror -control codi ng techni ques.
Thi s tool box i mpl ements two mai n types of err or-control codi ng techni ques:
bl ock and convol uti onal codi ng. The ki nds of bl ock code supported i ncl ude:
Hammi ng code
BCH code
Reed-Sol omon code
Cycl i c code
Li near bl ock code
Convol uti onal code does not break down i nto di ffer ent schemes.
There are two mai n types of decodi ng used wi th er ror-contr ol codes: al gebr ai c
and probabi l i sti c. Al gebrai c decodi ng i s usual l y used wi th bl ock codes, and
probabi l i sti c decodi ng i s usual l y used wi th convol uti onal codes. For a more
detai l ed di scussi on of err or-contr ol codi ng and decodi ng, refer to chapter 3, the
Tutorial.
Thi s fi gure shows the Err or -Contr ol Codi ng Subl i brary:Fi gure 6-8:
Figure 6-8: Error-Control Coding Sublibrary
6-54
Error-Control Coding Reference Table
Thi s tabl e l i sts the Si mul i nk bl ocks i n the Err or-Contr ol subl i brar y.
(They are l i sted al phabeti cal l y i n thi s tabl e for your conveni ence.):
Block Name Description
BCH Code Vi ew Tabl e Gener ates and di spl ays a tabl e of
codewor d l ength, message l ength,
and err or -cor recti on capabi l i ty for
BCH codes
BCH Decode Sequence I n/Out Decodes BCH encoded data i n the
sequenti al i n/out format
BCH Decode Vector I n/Out Decodes BCH encoded data i n the
vector i n/out for mat
BCH Encode Sequence I n/Out Encodes data usi ng BCH code i n the
sequenti al i n/out format
BCH Encode Vector I n/Out Encodes data usi ng BCH code i n the
vector i n/out for mat
Convol uti onal Decode
Sequence I n/Out
Decodes convol uti onal l y encoded
data i n the sequenti al i n/out format
Convol uti onal Decode Vector I n/Out Decodes convol uti onal l y encoded
data i n the vector i n/out format
Convol uti onal Encode
Sequence I n/Out
Encodes data usi ng Convol uti on
code i n the sequenti al i n/out format
Convol uti onal Encode Vector I n/Out Encodes data usi ng Convol uti on
code i n the vector i n/out for mat
Cycl i c Decode Sequence I n/Out Decodes cycl i c encoded data i n the
sequenti al i n/out format
Cycl i c Decode Vector I n/Out Decodes cycl i c encoded data i n the
vector i n/out for mat
6-55
Cycl i c Encode Sequence I n/Out Encodes data usi ng cycl i c code i n
the sequenti al i n/out format
Cycl i c Encode Vector I n/Out Encodes data usi ng cycl i c code i n
the vector i n/out format
Hammi ng Decode Sequence I n/Out Decodes Hammi ng encoded data i n
the sequenti al i n/out format
Hammi ng Decode Vector I n/Out Decodes Hammi ng encoded data i n
the vector i n/out format
Hammi ng Encode Sequence I n/Out Encodes data usi ng Hammi ng code
i n the sequenti al i n/out for mat
Hammi ng Encode Vector I n/Out Encodes data usi ng Hammi ng code
i n the vector i n/out format
Li near Bl ock Decode
Sequence I n/Out
Decodes l i near bl ock encoded data
i n the sequenti al i n/out for mat
Li near Bl ock Decode Vector I n/Out Decodes l i near bl ock encoded data
i n the vector i n/out format
Li near Bl ock Encode
Sequenti al I n/Out
Encodes data usi ng l i near bl ock
code i n the sequenti al i n/out format
Li near Bl ock Encode Vector I n/Out Encodes data usi ng l i near bl ock
code i n the vector i n/out for mat
Reed-Sol omon Decode
Bi nary Sequence I n/Out
Decodes R-S encoded data i n the
bi nary sequenti al i n/out for mat
Reed-Sol omon Decode
Bi nary Vector I n/Out
Decodes R-S encoded data i n the
bi nary vector i n/out format
Reed-Sol omon Decode
I nteger Sequence I n/Out
Decodes R-S encoded data i n the
i nteger sequenti al i n/out format
Reed-Sol omon Decode
I nteger Vector I n/Out
Decodes R-S encoded data i n the
i nteger vector i n/out for mat
Block Name Description
6-56
Reed-Sol omon Encode
Bi nary Sequence I n/Out
Encodes data usi ng R-S code i n the
bi nary sequenti al i n/out for mat
Reed-Sol omon Encode
Bi nary Vector I n/Out
Encodes data usi ng R-S code i n the
bi nary vector i n/out format
Reed-Sol omon Encode
I nteger Sequence I n/Out
Encodes data usi ng R-S code i n the
i nteger sequenti al i n/out format
Reed-Sol omon Encode
I nteger Vector I n/Out
Encodes data usi ng R-S code i n the
i nteger vector i n/out for mat
Block Name Description
Hamming Encode Vector In/ Out
6-57
6
Hammi ng Encode
Vector I n/Out
Catagory Err or-contr ol encoder
Location Err or-Control Codi ng Subl i br ary
Description The Hammi ng Encode Vector I n/Out bl ock encodes a bi nary message vector
i nto a bi nary codeword vector . Hammi ng encodi ng i s a for m of l i near encodi ng
i n whi ch message and codeword l engths ar e fi xed. The codewor d l ength (N) i s
2
M
-1 and the message l ength (K) i s 2
M
-M-1, where M i s an i nteger gr eater than
or equal to 3. Hammi ng code i s a si ngl e er ror cor recti on code.
You can use the hammgen functi on to pr oduce the Hammi ng code gener ator
matr i x and pari ty-check matri x par ameter s.
Dialog Box
Characteristics No. of I nputs/Output 1/1
Vector i zed I nputs/ Outputs Yes/Yes
I nput Vector Wi dth Row Number of Generator Matr i x
Output Vector Wi dth Col umn Number of Generator Matr i x
Ti me Base Auto
States N/A
Di r ect Feedthrough Yes
Pair Block Hammi ng Decode Vector I n/Out
Codewor d l ength (N).
Message l ength (K). When thi s entry i s a vector ,
i t repr esents a pr i mi ti ve pol ynomi al i n the GF(2)
fi el d. You can constr uct a pr i mi ti ve pol ynomi al
Hamming Decode Vector In/ Out
6-58
Hammi ng Decode
Vector I n/Ou t
Catagory Err or-control decoder
Location Err or-Contr ol Codi ng Subl i br ary
Description The Hammi ng Decode Vector I n/Out bl ock recover s a message vector fr om a
codeword vector usi ng Hammi ng code. The i nput parameter s for thi s bl ock
must match the par ameters used i n the Hammi ng Encode bl ock i n order to
obtai n the corr ect resul t.
Dialog Box
Characteristics No. of I nputs/Output 1/1
Vector i zed I nputs/ Outputs Yes/Yes
I nput Vector Wi dth Row Number of Generator Matr i x
Output Vector Wi dth Col umn Number of Gener ator Matri x
Ti me Base Auto
States N/A
Di r ect Feedthrough Yes
Pair Block Hammi ng Encode Vector I n/Out
Match the codewor d l ength N and the message
l ength K to the cor r espondi ng entr i es i n the
Hammi ng Encode bl ock.
Hamming Encode Sequence In/ Out
6-59
Hammi n g Encode
Sequence I n /Out
Catagory Err or-contr ol encoder
Location Err or-Control Codi ng Subl i br ary
Description The Hammi ng Encode Sequence I n/Out bl ock encodes a bi nar y message i nto a
bi nary codeword usi ng a sequenti al i n/out format. Hammi ng codi ng i s a speci al
case of l i near bl ock codi ng where the message and codewor d l engths are fi xed.
Hammi ng code i s a si ngl e er ror cor recti on code. I n the sequenti al format, the
bl ock hol ds the i nput message bi ts i n a l ength K buffer . When the buffer i s
l oaded, the encodi ng process begi ns. The bl ock outputs the l ength N codeword
i n a bi t str eam.
The codeword l ength i s al ways N=2
M
-1, wher e M i s an i nteger gr eater or equal
to 3. The message l ength i s K=2
M
-M-1. You can use the hammge n functi on to
constr uct the Hammi ng code generator matri x and pari ty-check matri x
parameter s.
The rel ati on between the output and i nput sampl e ti mes i s:
out put _s ampl e_t i me =i nput _s ampl e _t i me K/N
Because encodi ng cannot begi n unti l the i nput buffer i s ful l , thi s encodi ng
method i ntroduces a del ay between the ar ri val of the fi r st message si gnal and
the outputti ng of the fi rst codeword. The ti me del ay i s:
KI nput _s ampl e _t i me
Output port 1 outputs the codeword i n bi nary sequenti al for m. Output port 2
outputs an i mpul se, that i s, i t outputs 1 when the output r egi ster i s ful l and
0 at al l other ti mes.
Hamming Encode Sequence In/ Out
6-60
Dialog Box
Characteristics No. of I nputs/Outputs 1/2
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete-ti me, Mul ti -rate
States N/A
Di r ect Feedthrough Yes
Del ay I nput_Sampl e_Ti me K
Pair Block Hammi ng Decode Sequence I n/Out
Codewor d l ength (N)
Message l ength. When thi s entr y i s a vector , i t
r epr esents a pr i mi ti ve pol ynomi al i n the GF(2)
fi el d. You can constr uct pr i mi ti ve pol ynomi al s
usi ng the MATLAB M-functi on gf pr i mf d.
The ti me i nterval for each i nput bi t i n the
sequence.
Hamming Decode Sequence In/ Out
6-61
Hammi ng Decode
Sequence I n /Out
Catagory Err or-contr ol decoder
Location Err or-Control Codi ng Subl i br ary
Description The Hammi ng Decode Sequence I n/Out bl ock recovers a bi nar y message vector
from a bi nary codewor d vector usi ng Hammi ng decodi ng techni que. The i nput
parameter s for thi s bl ock must match the parameter s used i n the Hammi ng
Encode bl ock i n or der to obtai n the cor rect r esul t. I n the sequenti al for mat, the
bl ock hol ds the i nput codeword bi ts i n a l ength N buffer. When the buffer i s
l oaded, the decodi ng process begi ns. The bl ock outputs the l ength K r ecovered
message i n a bi t stream.
The rel ati on between the i nput and output sampl e ti mes i s:
i nput _s ampl e _t i me = out put _s ampl e _t i me N/K
Thi s bl ock i ntroduces a del ay between the arr i val of the fi r st codewor d si gnal
and the outputti ng of the fi rst recover ed message si gnal . The ti me del ay l ength
i s:
K Out put _Sampl e_Ti me
Dialog Box
Match the codewor d l ength N and the message
l ength K to the corr espondi ng entri es i n the
Hammi ng Encode bl ock.
The ti me i nter val for each i nput bi t i n the
sequence. The output sampl e ti me equal s the
i nput _s ampl e_t i me K/N.
Hamming Decode Sequence In/ Out
6-62
Characteristics No. of I nputs/Output 1/1
Vector i zed I nputs/ Outputs No/No
Ti me Base Di scr ete-ti me, Mul ti -rate
States N/A
Di r ect Feedthrough Yes
Del ay I nput_Sampl e_Ti me K
Pair Block Hammi ng Encode Sequence I n/Out
BCH Code View Table
6-63
BCH Code
Vi ew Tabl e
Catagory Create a vi ew tabl e for BCH par ameters
Location Err or-Control Codi ng Subl i br ary
Description The BCH Code Vi ew Tabl e bl ock cr eates a tabl e of codeword l ength, message
l ength, and err or -corr ecti on capabi l i ty for BCH codes. The BCH codeword i s of
l ength 2
M
-1, wher e M i s a posi ti ve i nteger gr eater than or equal to 3. The
message l ength depends on the l ength of the cosets i n the Gal oi s fi el d GF(2
M
).
The err or-cor recti on capabi l i ty i s more compl i cated; ther e i s no cl osed-formul a
for der i vi ng the rel ati onshi p between er ror -corr ecti on capabi l i ty and the
codewor d and message l engths.
Thi s bl ock provi des a vi ew tabl e for codewor d l engths 2
M
-1, where M ranges
from 3 thr ough 9. The fi gure on the fol l owi ng page shows the vi ew tabl e as i t
appears i n the BCH Code Vi ew Tabl e bl ock. I n thi s tabl e, N i s the codeword
l ength, K the val i d message l ength determi ned by the cal cul ati on of cosets, and
T i s the er ror-corr ecti on capabi l i ty for the gi ven N and K val ues. T i s
determi ned by an exhausti ve sear ch.
BCH Code View Table
6-64
Figure 6-9: BCH View Table
For val ues of M l arger than 9, use the bc hpol y functi on.
BCH Code View Table
6-65
Equivalent
M-function
bc hpol y
BCH Encode Vector In/ Out
6-66
BCH Encode
Vector I n/Ou t
Catagory Err or-control encoder
Location Err or-Contr ol Codi ng Subl i br ary
Description The BCH Encode Vector I n/Out bl ock encodes a message vector i nto a codewor d
vector . BCH codi ng i s a wi del y used err or contr ol codi ng method for corr ecti ng
the err or i nduced by r andom noi se i n the tr ansmi ssi on channel .
The BCH codeword l ength (N) i s 2
M
-1, where M i s a posi ti ve i nteger greater than
or equal to 3. The message l ength (K) depends upon the si ze of the cosets of GF(2
M
).
There i s currentl y no anal yti c formul a to deri ve the rel ati onshi p between the
error-correcti on capabi l i ty and the codeword and message l engths. You can use the
BCH Code Vi ew Tabl e bl ock or bchpol y functi on to cal cul ate the error-correcti on
capabi l i ty and possi bl e message l engths for codeword l engths 3 thr ough 9.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs Yes/Yes
I nput Vector Wi dth Message Length
Output Vector Wi dth Codeword Length
Ti me Base Auto
States N/A
Di r ect Feedthrough Yes
Pair Block BCH Decode Vector I n/Out
Equivalent
M-function
encode
Codewor d l ength (N).
Message l ength (K) must be l ess than the
codeword l ength.
BCH Decode Vector In/ Out
6-67
BCH Decode
Vector I n/Out
Catagory Err or-contr ol decoder
Location Err or-Control Codi ng Subl i br ary
Description The BCH Decode Vector I n/Out bl ock r ecover s a bi nar y message vector fr om a
codewor d vector usi ng BCH codi ng techni ques. The i nput parameters for thi s
bl ock must match the par ameters used i n the BCH Encode bl ock i n order to
obtai n the corr ect resul t.
I nput por t 1 accepts the codewor d vector and i nput port 2 accepts a
computati on fl ag si gnal . Thi s si gnal contr ol s the decode computati on. A
nonzer o i nput on thi s port enabl es the BCH decodi ng and a zer o i nput di sabl es
BCH decodi ng. Thi s contr ol i s necessary because BCH decodi ng i s
computati onal l y i ntensi ve.
Output port 1 outputs the recovered message. Output por t 2 outputs the
number of err ors detected dur i ng the r ecover y of the message. A negati ve
i nteger i ndi cates that the number of error s detected exceeds the
err or-cor recti on capabi l i ty of the sel ected BCH codi ng scheme.
Use the BCH Code Vi ew Tabl e bl ock or bc hpol y functi on to cal cul ate the
err or-cor recti on capabi l i ty.
Dialog Box
Codewor d l ength (N).
Message l ength (K).
Er r or -corr ecti on capabi l i ty. I f thi s par ameter i s
unknown, enter i ng a 0 for ces the bl ock to cal cu-
l ate the err or -control capabi l i ty at i ni ti al i zati on.
BCH Decode Vector In/ Out
6-68
Characteristics No. of I nputs/Outputs 2/2
Vector i zed No. 1 I nput Yes
No. 1 I nput Vector Length No
Vector i zed No. 2 I nput No
Vector i zed No. 1 Output Yes
No. 1 Output Vector Length K
Vector i zed No. 2 Output No
Ti me Base Auto
States N/A
Di r ect Feedthrough Yes
Pair Block BCH Encode Vector I n/Out
Equivalent
M-function
de code
BCH Encode Sequence In/ Out
6-69
BCH Encode
Sequence I n/Out
Catagory Err or-contr ol encoder
Location Err or-Control Codi ng Subl i br ary
Description The BCH Encode Sequence I n/Out bl ock encodes a bi nary message vector i nto
a codewor d usi ng a sequence i n/out format. BCH codi ng i s a wi del y used err or
control codi ng method for cor recti ng the err or i nduced by r andom noi se i n the
tr ansmi ssi on channel . I n the sequenti al for mat, the bl ock hol ds the i nput
message bi ts i n a l ength K buffer. When the buffer i s l oaded, the encodi ng
process begi ns. The bl ock outputs the l ength N codewor d i n a bi t str eam.
The BCH codewor d l ength (N) i s 2
M
-1, where M i s a posi ti ve i nteger greater
than or equal to 3. The message l ength (K) depends upon the si ze of the cosets
of GF(2
M
). There i s curr entl y no anal yti c for mul a to der i ve the rel ati onshi p
between the er ror-corr ecti on capabi l i ty and the codewor d and message l engths.
Pl ease r efer to the BCH Code Vi ew Tabl e bl ock for a l i st of er ror cor recti on
capabi l i ti es and possi bl e message l engths for codeword l engths 3 thr ough 9.
You can use the functi on bchpol y to fi nd the codeword, message l ength and
err or-cor recti on capabi l i ty sui tabl e to your appl i cati on.
The rel ati onshi p between the output and i nput sampl e ti mes i s:
out put _s ampl e_t i me = i nput _s ampl e _t i me K/N
Output port 1 outputs the codeword i n bi nary sequenti al for m. Output port 2
outputs an i mpul se, that i s, i t outputs a 1 at the when the i nput regi ster i s
ful l and a 0 at al l other ti mes.
BCH Encode Sequence In/ Out
6-70
Dialog Box
Characteristics No. of I nputs/Outputs 1/2
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete-ti me, Mul ti -rate
States N/A
Di r ect Feedthrough Yes
Del ay I nput_Sampl e_Ti me K
Pair Block BCH Decode Sequence I n/Out
Equivalent
M-function
encode
Codewor d l ength (N).
Message l ength (K) must be l ess than the
codeword l ength.
The ti me i nterval for each i nput bi t i n the
sequence. The output sampl e ti me equal s
the i nput _s ampl e_t i me K/N.
BCH Decode Sequence In/ Out
6-71
BCH Decode
Sequence I n /Out
Catagory Err or-contr ol decoder
Location Err or-Control Codi ng Subl i br ary
Description The BCH Decode Sequence I n/Out bl ock r ecovers a bi nary message fr om a
codewor d usi ng a sequenti al i n/out for mat. The i nput par ameters for thi s bl ock
must match the par ameters used i n the BCH encode bl ock to obtai n the cor rect
resul t. I n the sequenti al for mat, the bl ock hol ds the i nput codewor d bi ts i n a
l ength N buffer. When the buffer i s l oaded, the encodi ng pr ocess begi ns. The
bl ock outputs the l ength K recover ed message i n a bi t stream.
The i nput port accepts the codewor d vector . Output port 1 outputs the
recovered message, and output port 2 outputs the number of err ors detected
dur i ng the r ecover y of the message. A negati ve i nteger i ndi cates that the
number of err ors detected exceeds the err or-cor recti on capabi l i ty of the
sel ected BCH codi ng scheme.
The rel ati onshi p between the i nput and output sampl e ti mes i s:
i nput _s ampl e _t i me = out put _s ampl e _t i me K/N
Because decodi ng cannot begi n unti l the i nput buffer i s ful l , thi s bl ock
i ntroduces a ti me del ay. The del ay between the ar ri val of the fi r st codeword
and the output of the fi rst r ecover ed message i s:
K out put _s ampl e_t i me
BCH Decode Sequence In/ Out
6-72
Dialog Box
Characteristics No. of I nputs/Outputs 1/2
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete-ti me, Mul ti -rate
States N/A
Di r ect Feedthrough Yes
Del ay I nput_Sampl e_Ti me K
Pair Block BCH Decode Sequence I n/Out
Equivalent
M-function
encode
Match the codewor d l ength N and the message
l ength K to the cor respondi ng entr i es i n the BCH
Encode bl ock.
Er ror -cor r ecti on capabi l i ty. I f thi s parameter i s
unknown, enteri ng a 0 for ces the bl ock to cal cu-
l ate the err or -contr ol capabi l i ty at i ni ti al i zati on.
The ti me i nterval for each i nput bi t i n the
sequence. The output sampl e ti me equal s the
i nput _s ampl e_t i me K/N.
Reed-Solomon Encode Integer Vector In/ Out
6-73
Reed-Sol omon En code
I nteger Vector I n/Out
Catagory Err or-contr ol encoder
Location Err or-Control Codi ng Subl i br ary
Description The Reed-Sol omon Encode I nteger Vector I n/Out bl ock encodes an i nteger
vector message i nto a codewor d vector usi ng an i nteger vector i n/out format.
Reed-Sol omon (R-S) code i s a burst-er ror cor recti on code. Pl ease refer to
Chapter 3, the Tutorial, or reference [28] for a di scussi on of R-S codi ng
techni ques.
The el ements i n R-S codi ng ar e i n GF(2
M
), a fi ni te fi el d that contai ns 2
M

el ements, where M i s an i nteger gr eater than or equal to 3. Thi s bl ock supports
i nteger si gnal s that range i n val ue from 0 to 2
M
-1. An (N,K) Reed-Sol omon code
has codeword l ength (N) equal to 2
M
-1, message l ength (K), and par i ty-check
l ength (N-K). For an effi ci ent Reed-Sol omon code, N-K shoul d be an even
number.
For exampl e, i f M=3, the r ange of al l owed val ues i s 0-7. For a message vector
(K) of l ength 5, the codeword (N) i s of l ength 7 and the number of par i ty-check
di gi ts (N-K) i s 2:
The (N,K) Reed-Sol omon codi ng scheme i s an (NM,KM) bi twi se counti ng, and
i ts err or cor recti on capabi l i ty i s:
T = f l oor ( ( N- K) /2)
The corr ecti ons made i n the Reed-Sol omon code are i nteger cor recti ons, whi ch
means that every correcti on i s M-bi t.
I nput por t 1 accepts the i nput message, whi ch must be a l ength K i nteger
si gnal . I nput port 2 accepts the computati on fl ag si gnal , whi ch contr ol s the
decode computati on. A nonzer o scal ar i nput to thi s por t enabl es the R-S
encodi ng and a 0 i nput di sabl es R-S encodi ng. Thi s control i s necessar y because
R-S encodi ng i s computati onal l y i ntensi ve.
6 7 4 0 1
Reed-Sol omon
Encodi ng
3 2 6 7 4 0 1
Length (N) codewor d. The
fi rst (N-K) el ements ar e
pari ty-check di gi ts
Length (K)
message vector .
Reed-Solomon Encode Integer Vector In/ Out
6-74
Dialog Box
Characteristics No. of I nputs/Outputs 2/1
Vector i zed No. 1 I nput Yes
No. 1 I nput Vector Length N
Vector i zed No. 2 I nput No
Vector i zed Outputs Yes
Output Vector Length K
Ti me Base Auto
States N/A
Di r ect Feedthrough Yes
Pair Block Reed-Sol omon Encode I nteger Vector I n/Out
Equivalent
M-function
encode
Codewor d l ength (N).
Message l ength (K).
Reed-Solomon Decode Integer Vector In/ Out
6-75
Reed-Sol omon Decode
I nteger Vector I n/Out
Catagory Err or-contr ol decoder
Location Err or-Control Codi ng Subl i br ary
Description The Reed-Sol omon Decode I nteger Vector I n/Out bl ock r ecover s a message
vector from a codewor d usi ng an i nteger vector i n/out for mat. Pl ease read the
di scussi on of Reed-Sol omon (R-S) code i n Chapter 3, the Tutorial, for detai l s on
thi s codi ng method. The i nput parameter s for thi s bl ock must match the
parameter s used i n the Reed-Sol omon Encode bl ock i n or der to obtai n the
cor rect r esul t.
I nput por t 1 accepts a l ength N i nteger codewor d. The second accepts the
computati on fl ag si gnal , whi ch contr ol s the decode computati on. A nonzero
scal ar i nput to thi s port enabl es the R-S decodi ng and a 0 i nput di sabl es R-S
decodi ng. Thi s contr ol i s necessar y because R-S decodi ng i s computati onal l y
i ntensi ve.
Output port 1 outputs the recovered l ength K i nteger vector message. Output
port 2 outputs the number of err or s detected i n the decoded message. A
negati ve i nteger i ndi cates that the number of er ror s detected exceeds the
err or-cor recti on capabi l i ty of the R-S codi ng scheme.
Dialog Box
3 2 6 7 4 0 1
Reed-Sol omon
Decodi ng
6 7 4 0 1
Length (N) code-
word.
Recover ed l ength
(K) message vector .
Match the codewor d l ength N and the message
l ength K to the corr espondi ng entri es i n the
Reed-Sol omon Encode bl ock.
Reed-Solomon Decode Integer Vector In/ Out
6-76
Characteristics No. of I nputs/Outputs 2/2
Vector i zed No. 1 I nput Yes
No. 1 I nput Vector Length N
Vector i zed No. 2 I nput No
Vector i zed Outputs Yes
Output Vector Length K
Ti me Base Auto
States N/A
Di r ect Feedthrough Yes
Pair Block Reed-Sol omon Encode I nteger Vector I n/Out
Equivalent
M-function
de code
Reed-Solomon Encode Binary Vector In/ Out
6-77
Reed-Sol omon Encode
Bi n ary Vector I n/Out
Catagory Err or-contr ol encoder
Location Err or-Control Codi ng Subl i br ary
Description The Reed-Sol omon Encode Bi nary Vector I n/Out bl ock encodes a l ength K
bi nary vector i nto l ength N codeword. Unl i ke any other codi ng method
i ntroduced i n thi s tool box, Reed-Sol omon code i s a burst-err or corr ecti on code.
Pl ease r efer to Chapter 3, the Tutorial, for a di scussi on of Reed-
Sol omon codi ng techni ques. There i s al so a detai l ed di scussi on i n reference
[28].
I n the bi nary vector format, al l i nput/output si gnal s ar e vector s wi th bi nary
el ements. The el ements i n Reed-Sol omon (R-S) codi ng ar e i n GF(2
M
), a fi ni te
fi el d that contai ns 2
M
el ements, wher e M i s an i nteger greater than or equal to
3. An (N,K) Reed-Sol omon code has codewor d l ength N=2
M
-1 and message
l ength K that i s l ess than N. For effi ci ent codi ng the par i ty-check l ength (N-K)
shoul d be an even i nteger . For exampl e, i f M=3, the codewor d l ength (N) i s 7,
and to make the pari ty-check l ength (N-K) even l ength (K) can be set to 5:
The (N,K) Reed-Sol omon codi ng scheme i s an (NM,KM) code when counted
bi twi se. The err or corr ecti on capabi l i ty of Reed-Sol omon code i s:
T = f l oor ( ( N- K) /2)
The corr ecti ons made i n the Reed-Sol omon code are i nteger cor recti ons, whi ch
means that every correcti on i s M-bi t.
Thi s bl ock encodes a l ength MK bi nary message i nto a l ength MN bi nary
codewor d. The R-S encode bl ock i s l ength NM, the output si gnal i s l ength
KM.
1 0 1 1 0
Reed-Sol omon
Encodi ng
1 0 1 0 1 1 0
Length (K) bi nar y
message vector .
Length (N) bi nary
codewor d. The fi r st
(N-K) bi ts ar e
Reed-Solomon Encode Binary Vector In/ Out
6-78
I nput port 1 accepts the l ength NK message si gnal . I nput port 2 accepts the
computati on fl ag si gnal that control s the encode computati on. A nonzero scal ar
i nput to thi s port enabl es the R-S encodi ng and a 0 i nput di sabl es R-S encodi ng.
Thi s control i s necessar y because R-S decodi ng i s computati onal l y i ntensi ve.
Dialog Box
Characteristics No. of I nputs/Outputs 2/1
Vector i zed No. 1 I nput Yes
No. 1 I nput Vector Length KM
Vector i zed No. 2 I nput No
Vector i zed Outputs Yes
Output Vector Length NM
Ti me Base Auto
States N/A
Di r ect Feedthrough Yes
Pair Block Reed-Sol omon Decode Bi nary Vector I n/Out
Equivalent
M-function
encode
Codewor d l ength (N).
Message l ength (K).
Reed-Solomon Decode Binary Vector In/ Out
6-79
Reed-Sol omon Decode
Bi nar y Vector I n/Out
Catagory Err or-contr ol decoder
Location Err or-Control Codi ng Subl i br ary
Description The Reed-Sol omon Decode Bi nar y Vector I n/Out bl ock recovers a bi nary
message vector from a bi nar y codewor d vector. Pl ease read the di scussi on of
Reed-Sol omon (R-S) code i n Chapter 3, the Tutorial, for detai l s on thi s codi ng
method. The i nput par ameters for thi s bl ock must match the par ameters used
i n the Reed-Sol omon Encode bl ock i n or der to obtai n the cor rect r esul t.
Thi s bl ock accepts l ength N bi nar y vector codewords. Length (N) i s equal to
2M-1, wher e M i s an i nteger greater than or equal to 3. The recovered message
l ength (K) i s l ess than N, typi cal l y an odd i nteger :
I nput por t 1 accepts the l ength N bi nar y codewor d. I nput port 2 accepts the
computati on fl ag si gnal , whi ch contr ol s the decode computati on. A nonzero
scal ar i nput to thi s port enabl es the R-S decodi ng and a 0 i nput di sabl es R-S
decodi ng. Thi s contr ol i s necessar y because R-S decodi ng i s computati onal l y
i ntensi ve.
Output port 1 outputs the recovered l ength K bi nar y vector message. Output
port 2 outputs the number of err or s detected i n the decoded message. A
negati ve i nteger i ndi cates that the number of er ror s detected exceeds the
err or-cor recti on capabi l i ty of the R-S codi ng scheme.
1 0 1 1 0 1 0
Reed-Sol omon
Decodi ng
1 1 0 1 0
Length (N) codewor d.
The fi r st (N-K) el ements
ar e par i ty-check bi ts.
Recover ed l ength
(K) message vector.
Reed-Solomon Decode Binary Vector In/ Out
6-80
Dialog Box
Characteristics No. of I nputs/Outputs 2/2
Vector i zed No. 1 I nput Yes
No. 1 I nput Vector Length KM
Vector i zed No. 2 I nput No
Vector i zed Outputs Yes
Output Vector Length NM
Ti me Base Auto
States N/A
Di r ect Feedthrough Yes
Pair Block R-S Encode Bi nar y Vector I n/Out
Equivalent
M-function
de code
Match the codewor d l ength N and the message
l ength K to the cor r espondi ng entr i es i n the
Reed-Sol omon Encode bl ock.
Reed-Solomon Encode Integer Sequence In/ Out
6-81
Reed-Sol omon En code
I nteger Sequence I n /Out
Catagory Err or-contr ol encoder
Location Err or-Control Codi ng Subl i br ary
Description The Reed-Sol omon Encode I nteger Sequence I n/Out bl ock encodes an i nteger
message i nto a codewor d usi ng an i nteger sequenti al i n/out format.
Reed-Sol omon (R-S) code i s a burst-er ror cor recti on code. Pl ease refer to
Chapter 3, the Tutorial, or reference [28] for a di scussi on of Reed-Sol omon
codi ng techni ques. I n the i nteger sequenti al format, the bl ock hol ds the i nput
message i ntegers i n a l ength K i nteger buffer . When the buffer i s l oaded, the
encodi ng process begi ns. The bl ock outputs the i nteger l ength N codewor d one
i nteger at a ti me.
The el ements i n Reed-Sol omon codi ng ar e i n GF(2
M
), a fi ni te fi el d that contai ns
2
M
el ements. M i s an i nteger greater than or equal to 3. An (N,K)
Reed-Sol omon code has codeword l ength N=2
M
-1 and message l ength K. The
el ements i n the codewor d and message are from GF(2
M
). The (N,K)
Reed-Sol omon codi ng scheme i s an (NM,KM) bi twi se counti ng. The er ror -
cor recti on capabi l i ty of Reed-Sol omon code i s:
T = f l oor ( ( N- K) /2)
For an effi ci ent Reed-Sol omon code, N-K shoul d be an even number. The
cor recti ons made i n the Reed-Sol omon code are i nteger corr ecti ons, whi ch
means that every correcti on i s M-bi t.
The codewor d output sampl e ti me i s di ffer ent from the i nput sampl e ti me. The
rel ati onshi p between the output and i nput sampl e ti mes i s:
out put _s ampl e_t i me =i nput _s ampl e _t i me K/N
Output port 1 outputs the codewor d i n i nteger sequenti al for m. Output por t 2
outputs an i mpul se, that i s, i t outputs a 1 at the onset of the encodi ng process
and a 0 at al l other ti mes.
Because the encodi ng pr ocess cannot begi n unti l the i nput i nteger buffer i s ful l ,
thi s bl ock i ntr oduces a del ay between the arr i val of the fi rst message si gnal and
the output of the fi rst codeword. The ti me del ay i s:
Ki nput _s ampl e _t i me
Reed-Solomon Encode Integer Sequence In/ Out
6-82
Dialog Box
Characteristics No. of I nputs/Outputs 1/2
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete-ti me, Mul ti -rate
States N/A
Di r ect Feedthrough Yes
Del ay I nput_Sampl e_Ti me K
Pair Block Reed-Sol omon I nteger Sequence I n/Out
Equivalent
M-function
encode
Codewor d l ength (N).
Message l ength (K), where K<N.
The ti me i nter val for each i nput i n the sequence.
Reed-Solomon Decode Integer Sequence In/ Out
6-83
Reed-Sol omon Decode
I nteger Sequence I n /Out
Catagory Err or-contr ol decoder
Location Err or-Control Codi ng Subl i br ary
Description The Reed-Sol omon Decode I nteger Sequence I n/Out bl ock recover s a message
from a codeword usi ng an i nteger sequenti al i n/out format. Pl ease r ead the
di scussi on of Reed-Sol omon (R-S) code i n Chapter 3, the Tutorial, for detai l s on
thi s codi ng method. The i nput parameter s for thi s bl ock must match the
parameter s used i n the Reed-Sol omon Encode bl ock i n or der to obtai n the
cor rect r esul t.
I n the sequenti al format, the bl ock hol ds the i nput i nteger codewor d i n a l ength
N i nteger buffer . When the buffer i s l oaded, the decodi ng process begi ns. The
bl ock outputs the l ength K recover ed message one i nteger at a ti me.
Output port 1 outputs the recovered l ength K i nteger sequenti al message.
Output port 2 outputs the number of err ors detected i n the decoded message.
A negati ve i nteger i ndi cates that the number of er rors detected exceeds the
err or-cor recti on capabi l i ty of the R-S codi ng scheme.
Thi s bl ock requi res i nfor mati on about the output sampl e ti me. The
rel ati onshi p between the i nput and output sampl e ti mes i s:
i nput _s ampl e _t i me=out put _s ampl e _t i me K/N
Because the decodi ng pr ocess cannot begi n unti l the i nteger i nput buffer i s ful l ,
the bl ock i ntroduces a del ay between the ar ri val of the fi r st codeword and the
output of the fi rst r ecover ed message. Thi s del ay i s:
Kout put _s ampl e_t i me
Reed-Solomon Decode Integer Sequence In/ Out
6-84
Dialog Box
Characteristics No. of I nputs/Outputs 1/2
Vector i zed I nput/Outputs No/No
Ti me Base Di scr ete-ti me, Mul ti -rate
States N/A
Di r ect Feedthrough Yes
Del ay I nput_Sampl e_Ti me K
Pair Block Reed-Sol omon I nteger Sequence I n/Out
Equivalent
M-function
de code
Match the codewor d l ength N and the message
l ength K to the cor r espondi ng entr i es i n the
Reed-Sol omon Encode bl ock.
The ti me i nter val for each i nput i n the sequence.
The output sampl e ti me equal s the
i nput _s ampl e_t i me K/N.
Reed-Solomon Encode Binary Sequence In/ Out
6-85
Reed-Sol omon Encode
Bi nar y Sequence I n/Out
Catagory Err or-contr ol encoder
Location Err or-Control Codi ng Subl i br ary
Description The Reed-Sol omon Encode Bi nary Sequence I n/Out bl ock encodes a message
i nto a codewor d usi ng a bi nary sequenti al i n/out for mat. Reed-Sol omon (R-S)
code i s a burst-er ror corr ecti on code. Pl ease refer to the Communications
Fundamentals chapter or r efer ence [28] for a di scussi on of Reed-Sol omon
codi ng techni ques.
The el ements i n Reed-Sol omon codi ng ar e i n GF(2
M
), a fi ni te fi el d that contai ns
2
M
el ements. M i s an i nteger greater than or equal to 3. An (N,K)
Reed-Sol omon code has codewor d l ength N=2
M
-1 and message l ength K, where
K i s an i nteger l ess than M. Si nce the err or cor recti on capabi l i ty of R-S codi ng
i s:
f l oor ( ( N- K) /2)
i t i s more effi ci ent to choose K so that (N-K) i s an even number.
An (N,K) R-S code refers to the codewor d l ength (N) and message l ength (K) i n
i nteger for m. Thi s means that each el ement of the codewor d and message i s
M-bi t, and that the code i s actual l y (NM,KM) when counted bi twi se.
The corr ecti ons made i n the Reed-Sol omon code are i nteger cor recti ons, whi ch
means that every correcti on i s M-bi t.The codewor d output sampl e ti me i s
di ffer ent from the i nput sampl e ti me. The r el ati onshi p between the two i s:
out put _s ampl e_t i me =i nput _s ampl e _t i me K/N
Output port 1 outputs the codewor d i n i nteger sequenti al for m. Output por t 2
outputs an i mpul se, that i s, i t outputs a 1 at the onset of the encodi ng process
and a 0 at al l other ti mes.
Thi s bl ock i ntroduces a del ay between the arr i val of the fi r st message si gnal
and the output of the fi rst codeword. The ti me del ay i s:
MKi nput _s ampl e_t i me
The sequenti al i n/out format br eaks down i nto fi ve steps:
Reed-Solomon Encode Binary Sequence In/ Out
6-86
1 1 0 0 1 0 1 1 ...
1 1 0 1
1 1 1 0 0 0 0 1 1 0 0 1 0 1 1
1 0 0 1 0 1 1
1 0 0 1 0 1 1...
1
5
4
3
2
1 0 0 1 0 1 1
1 1
Bits arrive sequentially and
are loaded into a length
KM register. Here, K=5
and M=3.
The block converts the load-
ed information into a length
KM vector.
Message vector
Reed-Solomon
Encoding
A length NM codeword
vector. Here N=7, making
the length of the codeword
equal to 21.
1 0 0 1 0 1 1 1 0 0 1 0 1 1
The block loads the
length NM code-
word vector into an
output register.
The block outputs the bits
sequentially, first-in,
first-out.
Reed-Solomon Encode Binary Sequence In/ Out
6-87
Dialog Box
Characteristics No. of I nputs/Outputs 1/2
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete-ti me, Mul ti -rate
States N/A
Di r ect Feedthrough Yes
Del ay I nput_Sampl e_Ti me M K
Pair Block Reed-Sol omon Decode Bi nary Sequence I n/Out
Equivalent
M-function
enc ode
Codewor d l ength (N).
Message l ength (K), wher e K<N.
The ti me i nter val for each i nput bi t i n the
sequence.
Reed-Solomon Decode Binary Sequence In/ Out
6-88
Reed-Sol omon Decode
Bi nary Sequence I n/Out
Catagory Err or-control decoder
Location Err or-Contr ol Codi ng Subl i br ary
Description The Reed-Sol omon Decode Bi nar y Sequence I n/Out bl ock r ecovers a message
from a codeword usi ng a bi nar y sequenti al i n/out format. Pl ease r ead the
di scussi on of Reed-Sol omon (R-S) code i n Chapter 3, the Tutorial , for detai l s on
thi s codi ng method. The i nput parameter s for thi s bl ock must match the
parameter s used i n the Reed-Sol omon Encode bl ock i n or der to obtai n the
cor rect r esul t.
Output port 1 outputs the recover ed l ength K bi nary sequenti al message.
Output port 2 outputs the number of err or s detected i n the decoded message.
A negati ve i nteger i ndi cates that the number of err ors detected exceeds the
err or -cor recti on capabi l i ty of the R-S codi ng scheme.
Thi s bl ock requi res i nfor mati on about the output sampl e ti me. The
rel ati onshi p between the i nput and output sampl e ti mes i s:
i nput _s ampl e_t i me = out put _s ampl e _t i me K/N
The bl ock i ntr oduces a del ay between the ar ri val of the fi r st codewor d and the
output of the fi rst r ecovered message. Thi s del ay i s:
K M out put _s ampl e _t i me
Dialog Box
Match the codewor d l ength N and the message
l ength K to the cor r espondi ng entr i es i n the
Reed-Sol omon Encode bl ock.
The ti me i nterval for each i nput bi t i n the
sequence.
Reed-Solomon Decode Binary Sequence In/ Out
6-89
Characteristics No. of I nputs/Outputs 1/2
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete-ti me, Mul ti -rate
States N/A
Di r ect Feedthrough Yes
Del ay I nput_Sampl e_Ti me M K
Pair Block Reed-Sol omon Encode Bi nar y Sequence I n/Out
Equivalent
M-function
de c ode
Cyclic Encode Vector In/ Out
6-90
Cycl i c Encode
Vector I n/Ou t
Catagory Err or-control encoder
Location Err or-Contr ol Codi ng Subl i br ary
Description The Cycl i c Encode Vector I n/Out bl ock encodes a bi nar y message i nto a
codeword. Cycl i c codi ng i s a generi c codi ng techni que that r equi r es the use of a
cycl i c gener ator pol ynomi al . You can cr eate a cycl i c gener ator pol ynomi al wi th
the cy cl pol y functi on. The Cycl i c Encode and Cycl i c Decode bl ocks use
systemati c cycl i c codi ng.
The codeword vector l ength N must be 2
M
-1, wher e M i s an i nteger greater
than or equal to 3. The message vector l ength K must be l ess than the codeword
l ength N. The degree of the cycl i c pol ynomi al i s N-K.
Dialog Box
Characteristic No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs Yes/Yes
I nput Vector Wi dth Message Length
Output Vector Wi dth Codeword Length
Ti me Base Auto
States N/A
Di r ect Feedthrough Yes
Codewor d l ength (N).
Gener ator pol ynomi al defi ned i n the GF(2) fi el d.
The degr ee of the pol ynomi al must be l ess than
the codewor d l ength N. When thi s entr y i s a
scal ar, this block assumes that the enter ed val ue
i s the message l ength K. The bl ock then gener -
ates a defaul t cycl i c pol ynomi al usi ng the func-
ti on pr =c yc l pol y( N, K, ' mi n' ) .
Cyclic Encode Vector In/ Out
6-91
Pair Block Cycl i c Decode Vector I n/Out
Equivalent
M-function
enc ode
Cyclic Decode Vector In/ Out
6-92
Cycl i c Decode
Vector I n/Ou t
Catagory Err or-control decoder
Location Err or-Contr ol Codi ng Subl i br ary
Description The Cycl i c Decode Vector I n/Out bl ock r ecover s a bi nar y message vector from
a bi nar y codeword vector usi ng cycl i c decodi ng. The i nput parameter s for thi s
bl ock must match the par ameters used i n the Cycl i c Encode bl ock to obtai n the
cor rect r esul t.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs Yes/Yes
I nput Vector Wi dth Message Length
Output Vector Wi dth Codeword Length
Ti me Base Auto
States N/A
Di r ect Feedthrough YesPai r Bl ock
Cycl i c Encode Vector I n/Out
Equivalent
M-function
de code
Match the codewor d l ength N and the message
l ength K to the cor r espondi ng entr i es i n the
Cycl i c Encode bl ock.
Cyclic Encode Sequence In/ Out
6-93
Cycl i c En code
Sequence I n /Out
Catagory Err or-contr ol encoder
Location Err or-Control Codi ng Subl i br ary
Description The Cycl i c Encode Sequence I n/Out bl ock encodes a bi nary message i nto a
codewor d usi ng a sequenti al i n/out for mat. Cycl i c codi ng i s a gener i c codi ng
method that requi res the use of a cycl i c gener ator pol ynomi al . You can use the
functi on c yc l pol y to gener ate a pr oper cycl i c pol ynomi al . Both the
Cycl i c Encode and Cycl i c Decode bl ocks use systemati c cycl i c codi ng. I n the
sequenti al format, the bl ock hol ds the i nput message bi ts i n a l ength K buffer .
When the buffer i s l oaded, the encodi ng process begi ns. The bl ock outputs the
l ength N codeword i n a bi t str eam.
The codeword vector l ength N must be 2
M
-1, where M i s an i nteger greater
than or equal to 3. The message vector l ength K must be l ess than the codewor d
l ength N. The degree of the cycl i c pol ynomi al i s N-K.
The rel ati onshi p between the output and i nput sampl e ti mes i s:
out put _s ampl e_t i me =i nput _s ampl e _t i me K/N
Output port 1 outputs the codeword i n bi nary sequenti al for m. Output port 2
outputs an i mpul se, that i s, i t outputs 1 when the i nput r egi ster i s ful l and
0 at al l other ti mes.
Because encodi ng cannot begi n unti l the i nput buffer i s ful l , thi s encodi ng
method i ntroduces a del ay between the ar ri val of the fi r st message si gnal and
the output of the fi rst codeword. The ti me del ay i s:
KI nput _s ampl e _t i me .
Cyclic Encode Sequence In/ Out
6-94
Dialog Box
Characteristics No. of I nputs/Outputs 1/2
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete-Ti me, Mul ti -r ate
States N/A
Di r ect Feedthrough Yes
Del ay I nput_Sampl e_Ti me K
Pair Block Cycl i c Decode Sequence I n/Out
Equivalent
M-function
encode
Codewor d l ength (N).
Gener ator pol ynomi al defi ned i n the GF(2) fi el d.
The degr ee of the pol ynomi al must be l ess than
the codewor d l ength N. When thi s entr y i s a
scal ar, cyclic encode assumes that the enter ed
val ue i s the message l ength K. The bl ock then
gener ates a defaul t cycl i c pol ynomi al usi ng the
functi on pr =cy cl pol y ( N, K, ' mi n' ) .
The ti me i nterval for each i nput bi t i n the
sequence. The output sampl e ti me equal s the
i nput _s ampl e_t i me K/N.
Cyclic Decode Sequence In/ Out
6-95
Cycl i c Decode
Sequence I n /Out
Catagory Err or-contr ol decoder
Location Err or-Control Codi ng Subl i br ary
Description The Cycl i c Decode Sequence I n/Out bl ock recovers a bi nary message fr om a
bi nary codewor d usi ng a sequenti al i n/out for mat. The i nput parameter s for
thi s bl ock must match the par ameters used i n the Cycl i c Encode bl ock to obtai n
the cor rect r esul t. I n the sequenti al format, the bl ock hol ds the i nput codewor d
bi ts i n a l ength N buffer. When the buffer i s l oaded, the decodi ng pr ocess
begi ns. The bl ock outputs the l ength K recover ed message i n a bi t stream.
Dialog Box
Characteristics No. of I nputs/Outputs 1/2
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete-ti me, Mul ti -rate
States N/A
Di r ect Feedthrough Yes
Del ay I nput_Sampl e_Ti me K
Pair Block Cycl i c Encode Sequence I n/Out
Equivalent
M-function
de c ode
Match the codewor d l ength N and the message
l ength K to the corr espondi ng entri es i n the
Cycl i c Encode bl ock.
The ti me i nter val for each i nput bi t i n the
sequence. The output sampl e ti me equal s the
i nput _s ampl e_t i me K/N
Linear Block Encode Vector In/ Out
6-96
Li near Bl ock Encode
Vector I n/Ou t
Catagory Err or-control encoder
Location Err or-Contr ol Codi ng Subl i br ary
Description The Li near Bl ock Encode Vector I n/Out bl ock uses l i near bl ock encodi ng to
gener ate a bi nary codewor d vector from a bi nar y message segment. The i nput
message segment can be ei ther a bi nary vector or a bi nar y sequence. I ts l ength
i s equal to the number of rows (K) of the generator matr i x. The number of
el ements i n the output codeword equal s the number of col umns (N) i n the
gener ator matri x. You can pr oduce an appr opri ate generator matri x usi ng the
hammge n or c yc l gen functi on. The cor respondi ng decode bl ock r equi r es both
thi s gener ator matr i x and an er ror cor recti on tr uth tabl e to decode the output
of thi s bl ock.
Dialog Box
Characteristics No. of I nputs/Output 1/1
Vector i zed I nputs/ Outputs Yes/Yes
I nput Vector Wi dth Row Number of Generator Matr i x
Output Vector Wi dth Col umn Number of Gener ator Matri x
Ti me Base Auto
States N/A
Di r ect Feedthrough Yes
Pair Block Li near Bl ock Decode Vector I n/Out
A K-by-N matr i x, wher e K i s the message
l ength and the i nput vector l ength, and N i s the
codeword l ength.
Linear Block Decode Vector In/ Out
6-97
L i near Bl ock Decode
Vector I n/Out
Catagory Err or-contr ol decoder
Location Err or-Control Codi ng Subl i br ary
Description The Li near Bl ock Decode Vector I n/Out bl ock r ecover s a bi nar y message vector
from a bi nar y codeword vector by usi ng l i near bl ock decodi ng.
Li near bl ock code i s a gener i c codi ng method that r equi r es the speci fi cati on of
a gener ator matri x. Thi s bl ock uses the same gener ator matri x speci fi ed i n the
cor respondi ng encodi ng bl ock, as wel l as an er ror -corr ecti on tr uth tabl e.
Gener ate the truth tabl e usi ng ht r ut ht b.
Dialog Box
Characteristics No. of I nputs/Output 1/1
Vector i zed I nputs/ Outputs Yes/Yes
I nput Vector Wi dth Row Number of Generator Matr i x
Output Vector Wi dth Col umn Number of Generator Matr i x
Ti me Base Auto
States N/A
Di r ect Feedthrough Yes
Pair Block Li near Bl ock Encode Vector I n/Out
Generator matri x speci fi ed i n Li near Bl ock
Encode bl ock.
The l ogi c ci r cui t that deter mi nes err or bi t l oca-
ti on. The tabl e i s a 2
N-K
-by-N matr i x. When 0 i s
entered, the err or -contr ol code defaul ts to a
systemati c si ngl e er r or -cor recti on code.
Linear Block Encode Sequence In/ Out
6-98
Li near Bl ock Encode
Sequ ence I n/Out
Catagory Err or-control encoder
Location Err or-Contr ol Codi ng Subl i br ary
Description The Li near Bl ock Encode Sequence I n/Out bl ock performs er ror-contr ol
encodi ng usi ng l i near bl ock code wi th a sequenti al i nput/sequenti al output
for mat. The bl ock encodes a bi nary message i nto a bi nar y codeword. I n the
sequenti al for mat, the bl ock hol ds the i nput message bi ts i n a l ength K buffer .
When the buffer i s l oaded, the encodi ng pr ocess begi ns. The bl ock outputs the
l ength N codewor d i n a bi t stream.
The r el ati onshi p between the two i nput and output sampl e ti mes i s:
out put _s ampl e _t i me =i nput _s ampl e _t i meN/K
wher e N i s the codewor d l ength and K i s the message l ength. Because encodi ng
cannot begi n unti l the i nput buffer i s ful l , ther e i s a ti me del ay i ntr oduced by
the sequenti al for mat. The ti me del ay between the arr i val of the fi r st message
si gnal and the output of the fi rst codeword i s:
KI nput _Sampl e _Ti me
Output port 1 outputs the codeword i n sequenti al bi nary for m. Output port 2
outputs an i mpul se. The r ai si ng edge of the second output i ndi cates the star t
of the encode process.
Dialog Box
A K-by-N matr i x that gener ates the codewor d
si gnal fr om the message si gnal .
The ti me i nterval for each i nput bi t i n the
sequence. The output sampl e ti me equal s the
i nput _s ampl e_t i me K/N.
Linear Block Encode Sequence In/ Out
6-99
Characteristics No. of I nputs/Outputs 1/2
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete-ti me, Mul ti -rate
States N/A
Di r ect Feedthrough Yes
Del ay I nput_Sampl e_Ti me K
Pair Block Li near Bl ock Decode wi th Sequence I n/Out
Linear Block Decode Sequence In/ Out
6-100
Li near Bl ock Decode
Sequ ence I n/Out
Catagory Err or-control decoder
Location Err or-Contr ol Codi ng Subl i br ary
Description The Li near Bl ock Decode Sequence I n/Out bl ock recover s a bi nar y message
from a codeword usi ng l i near bl ock code i n a sequenti al i n/out format. The
gener ator matr i x used i n thi s bl ock must match the one used i n the Li near
Bl ock Encode bl ock i n or der to obtai n the cor rect r esul t. I n the sequenti al
for mat, the bl ock hol ds the i nput codeword bi ts i n a l ength N buffer. When the
buffer i s l oaded, the decodi ng pr ocess begi ns. The bl ock outputs the l ength K
recovered message i n a bi t str eam.
The r el ati onshi p between the two sampl e ti mes i s:
i nput _s ampl e_t i me=out put _s ampl e _t i meN/K
wher e N i s the codewor d l ength and K i s the message l ength. Because decodi ng
cannot begi n unti l the i nput buffer i s ful l , thi s bl ock i ntroduces a del ay between
the arr i val of the fi rst codewor d si gnal and the fi rst output. The ti me del ay
l ength i s:
KOut put _Sampl e_Ti me
Dialog Box
An K-by-N matr i x that generates the codewor d
si gnal fr om message si gnal .
A 2
N-K
-by-N matr i x that deter mi nes er r or bi t
l ocati on. Set thi s to 0 for a systemati c si ngl e
er r or-cor r ecti on code.
The ti me i nterval for each output bi t i n the
sequence.
Linear Block Decode Sequence In/ Out
6-101
Characteristics No. of I nputs/Output 1/1
Vector i zed I nputs/ Outputs No/No
Ti me Base Di scr ete-ti me, Mul ti -rate
States N/A
Di r ect Feedthrough Yes
Del ay I nput_Sampl e_Ti me K
Pair Block Li near Bl ock Decode Sequence I n/Out
Convolutional Encode Vector In/ Out
6-102
Convol u ti onal Encode
Vector I n/Ou t
Catagory Err or-control encoder
Location Err or-Contr ol Codi ng Subl i br ary
Description The Convol uti onal Encode Vector I n/Out bl ock encodes a message i nto a
codeword usi ng a vector i n/out format. Unl i ke bl ock codes, convol uti onal code
requi res i nfor mati on not onl y on the i ncomi ng message but al so on a fi xed
number of previ ous messages. Accordi ngl y, convol uti onal codes are cal l ed
(N,K,M) codes wher e N i s the codewor d l ength, K the message l ength, and M
the memor y l ength.
Because of the memor y l ength requi rement, convol uti onal code
i mpl ementati on i n thi s tool box r equi r es a tr ansfer functi on matr i x i n the
parameter Transfer function. An exampl e of how to bui l d a transfer functi on
usi ng Si mul i nk bl ock di agr ams i s presented i n the Generati ng Tr an_func bl ock
l ocated i n the Convol uti onal Codi ng/Decodi ng Subl i br ary. Fol l owi ng the r ul es
outl i ned i n the Gener ati ng Tran_func bl ock, you can bui l d your own Si mul i nk
bl ock di agram of the transfer functi on and use the str i ng name of the Si mul i nk
model as an i nput to the di al og box. The bl ock wi l l gener ate the cor rect tr ansfer
functi on. You can al so choose to i nput di r ectl y a matr i x repr esentati on of the
numer ator and denomi nator of a tr ansfer functi on.
I nput port 1 accepts the message si gnal , and the i nput port 2 accepts a tri gger
si gnal . The convol uti onal encodi ng pr ocess begi ns when the l eadi ng edge of the
si gnal crosses the speci fi ed threshol d val ue. You can use the Vector Pul se bl ock
to generate a tri gger si gnal for thi s i nput por t.
Dialog Box
Speci fy a tr ansfer functi on matr i x or the str i ng
name of a Si mul i nk bl ock di agr am.
Set the tr i gger si gnal thr eshol d.
Convolutional Encode Vector In/ Out
6-103
Characteristics No. of I nputs/Outputs 2/1
Vector i zed I nput 1/I nput 2 Yes/No
I nput No. 1 Vector l ength K
Vector i zed Output Yes
Output Vector l ength N
Ti me Base Tri ggered
States 2M, wher e M i s the number of regi sters i n the
convol uti onal codi ng str uctur e
Di r ect Feedthrough Depends on the tr ansfer functi on
Pair Block Convol uti onal Encode Vector I n/Out
Equivalent
M-files
enc ode
See Also For mor e i nformati on on how to constr uct transfer functi ons, see:
s i m2gen, s i m2t r an, s i m2l ogi
Convolutional Decode Vector In/ Out
6-104
Convol u ti onal Decode
Vector I n/Ou t
Catagory Err or-control decoder
Location Err or-Contr ol Codi ng Subl i br ary
Description The Convol uti onal Decode Vector I n/Out bl ock recover s a bi nar y codewor d
vector fr om a bi nary message vector usi ng the Vi terbi decodi ng al gor i thm.
Refer to Chapter 3, the Tutor i al , for a more detai l ed di scussi on of thi s
techni que. Thi s bl ock suppor ts both har d and soft deci si on decodi ng. Usi ng
the soft deci si on method requi res the defi ni ti on of tr ansfer pr obabi l i ti es.
I nput port 1 i nputs a l ength N bi nar y vector codeword. I nput por t 2 i nputs a
scal ar computati on tr i gger si gnal . You can use the Vector Pul se bl ock to
gener ate a tr i gger si gnal for thi s i nput por t.
Output port 1 outputs the recover ed message vector . Output port 2 outputs a
scal ar. Thi s output i s a metr i c val ue i n the case of soft deci si on decodi ng, and
the accumul ati ve di stance i n the case of hard deci si on decodi ng.
Dialog Box
Match the transfer functi on to the one used i n the
Convol uti onal Encode bl ock.
The del ay l ength. Set thi s to a number gr eater
than the memor y l ength M of the decoder .
The tr ansfer pr obabi l i ty. Set thi s to 0 for har d
deci si on decodi ng. Otherwi se, enter a K-by-N
matr i x of pr obabi l i ti es.
Tr el l i s fi gur e pl ot l ength. Set thi s to an i nteger
l ar ger than the memor y l ength M for a deci si on
track. Setti ng thi s to 0 suppr esses the tr el l i s pl ot.
Match the tr i gger si gnal thr eshol d to that of the
Convol uti onal Encode bl ock.
Convolutional Decode Vector In/ Out
6-105
Characteristics No. of I nputs/Outputs 2/2
Vector i zed No.1/No. 2 I nputs Yes/No
No. 1 I nput Vector l ength N
Vector i zed No. 1/No. 2 OutputsYes/No
No. 1 Output Vector l ength K
Ti me base Tri ggered
States Del ay_l ength 2
M
, where M i s the number
of r egi ster s i n the convol uti onal codi ng
str uctur e
Di r ect Feedthrough Yes
Del ay I nter val _between_tri gger Memor y_l ength
Pair Block Convol uti onal Encode Vector I n/Out
Equivalent
M-function
enc ode
Convolutional Encode Sequence In/ Out
6-106
Convol u ti onal Encode
Sequ ence I n/Out
Catagory Err or-control encoder
Location Err or-Contr ol Codi ng Subl i br ary
Description The Convol uti onal Encode Vector I n/Out bl ock encodes a message i nto a
codeword usi ng a bi nary sequenti al i n/out for mat. Unl i ke bl ock codes,
convol uti onal code requi res i nfor mati on not onl y on the i ncomi ng message but
al so on a fi xed number of previ ous messages. Accordi ngl y, convol uti onal codes
are cal l ed (N,K,M) codes where N i s the codewor d l ength, K the message
l ength, and M the memory l ength.
Because of the memor y l ength requi rement, convol uti onal code
i mpl ementati on i n thi s tool box r equi r es a tr ansfer functi on matr i x i n the
parameter Transfer function. An exampl e of how to bui l d a transfer functi on
usi ng Si mul i nk bl ock di agr ams i s presented i n the Generati ng Tr an_func bl ock
l ocated i n the Convol uti onal Codi ng/Decodi ng Subl i br ary. Fol l owi ng the r ul es
outl i ned i n the Generati ng Tran_func bl ock, you can bui l d your own bl ock
di agr am of the transfer functi on and use the stri ng name of the Si mul i nk model
as an i nput to the di al og box. The bl ock wi l l gener ate the corr ect transfer
functi on. You can al so choose to di r ectl y i nput a matr i x repr esentati on of the
numer ator and denomi nator of a tr ansfer functi on.
I nput port 1 accepts the message si gnal , and the i nput port 2 accepts a tri gger
si gnal . The convol uti onal encodi ng pr ocess begi ns when the l eadi ng edge of the
si gnal crosses the speci fi ed threshol d val ue. You can use the Vector Pul se bl ock
to generate a tri gger si gnal for thi s i nput por t.
Dialog Box
Speci fy a tr ansfer functi on matr i x or the str i ng
name of a Si mul i nk bl ock di agr am.
Set the i nput sampl e ti me.
Convolutional Encode Sequence In/ Out
6-107
Characteristics No. of I nputs/Outputs 1/2
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete-ti me, Mul ti -rate
States 2
M
, wher e M i s the number of r egi ster s i n
the convol uti onal codi ng str uctur e
Di r ect Feedthrough Yes
Del ay I nput_Sampl e_Ti me K
Pair Block Convol uti onal Decode Sequence I n/Out
Equivalent
M-function
enc ode
See Also For mor e i nformati on on how to constr uct transfer functi ons, see:
s i m2gen, s i m2t r an, s i m2l ogi
Convolutional Decode Sequence In/ Out
6-108
Convol u ti onal Decode
Sequ ence I n/Out
Catagory Err or-control encoder
Location Err or-Contr ol Codi ng Subl i br ary
Description The Convol uti onal Decode Sequence I n/Out bl ock recovers a bi nary message
from a bi nary codeword usi ng the sequenti al i n/out for mat. The techni que used
for decodi ng i s the Vi ter bi al gori thm. Refer to Chapter 3, the Tutorial, for a
more detai l ed di scussi on of thi s techni que.
Thi s bl ock suppor ts both hard and soft deci si on decodi ng. Soft deci si on
decodi ng r equi r es the defi ni ti on of a tr ansfer pr obabi l i ty matri x.
Dialog Box
Characteristics No. of I nputs/Outputs 1/2
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete-ti me, Mul ti -Rate
States N/A
Di r ect Feedthrough Yes
Del ay I n_Sampl e_Ti me K (Memory_l ength+1)
Match the transfer functi on to the one used i n the
Convol uti onal Encode bl ock.
The del ay l ength. Set thi s to a number gr eater
than the memor y l ength M of the decoder .
The tr ansfer pr obabi l i ty. Set thi s to 0 for har d
deci si on decodi ng. Otherwi se, enter a K-by-N
matr i x of pr obabi l i ti es, wher e K i s the message
l ength and N i s the codeword l ength.
Tr el l i s fi gur e pl ot l ength. Set thi s to an i nteger
l ar ger than the memor y l ength M for a deci si on
track. Setti ng thi s to 0 suppr esses the tr el l i s pl ot.
The ti me i nterval for each output bi t i n the
sequence. The output_sampl e_ti me
=i nput _s ampl e_t i me K/N
Convolutional Decode Sequence In/ Out
6-109
Pair Block Convol uti onal Encode Sequence I n/Out
Equivalent
M-function
de c ode
6-110
6
Modulation and Demodulation
I n communi cati on systems, i nformati on i s often tr ansmi tted by modul ati ng the
source si gnal onto a car ri er si gnal to form a modul ated si gnal . A modul ated
si gnal can be tr ansferred a l onger di stance wi th consi derabl y l ess energy
compar ed to an unmodul ated si gnal . The modul ated si gnal can al so shar e the
same tr ansmi tti ng medi a and bandwi dth wi th other modul ated si gnal s.
Modul ati on can be achi eved by a number of modul ati on techni ques. The
Communi cati ons Tool box supports the most commonl y used methods for
modul ati on and demodul ati on.
The Communi cati ons Tool box provi des both an anal og modul ati on/
demodul ati on l i brar y and a di gi tal modul ati on/demodul ati on l i brar y. Di gi tal
modul ati on can be di vi ded i nto two parts: di gi tal si gnal mappi ng and
modul ati on. A di gi tal demodul ati on can al so be di vi ded i nto two parts:
demodul ati on and di gi tal demappi ng. The di vi si on i s useful for detai l ed
research of the mappi ng/demappi ng techni ques and i n i ts combi nati on wi th
modul ati on/demodul ati on techni ques. Thi s tool box pr ovi des a l i brar y for the
mappi ng/demappi ng subl i brari es under the modul ati on/demodul ati on
category.
Thi s fi gure shows the Modul ati on/Demodul ati on Subl i brar y:
Figure 6-10: Modulation/ Demodulation Sublibrary
6-111
The fi rst col umn shows the subl i br ar i es of the passband si mul ati on bl ocks; the
second col umn shows the subl i br ari es of the baseband si mul ati on bl ocks. The
fi rst row shows the subl i brari es for anal og modul ati on. The second row shows
the subl i br ari es for di gi tal modul ati on. The thi r d r ow shows the subl i br ar i es
for mappi ng/demappi ng i n di gi tal modul ati on/demodul ati on.
Thi s chapter i ntroduces the bl ocks by goi ng thr ough each subl i br ary. Thi s
secti on i s further di vi ded i nto these fi ve subsecti ons:
Anal og Modul ati on/Demodul ati on Method for Passband Si mul ati on
Anal og Modul ati on/Demodul ati on Method for Baseband Si mul ati on
Mappi ng/Demappi ng for Di gi tal Modul ati on/Demodul ati on
Di gi tal Modul ati on/Demodul ati on Method for Passband Si mul ati on
Di gi tal Modul ati on/Demodul ati on Method for Baseband Si mul ati on
Analog Modulation/ Demodulation Methods for
Passband Simulation
The Communi cati ons Tool box i ncl udes these anal og modul ati on methods for
passband si mul ati on.
Doubl e si deband suppressed-carr i er ampl i tude modul ati on (DSB-SC AM)
DSB-SC wi th car ri er ampl i tude modul ati on (AM wi th Car ri er )
Quadr ature mul ti pl exi ng DSB-SC ampl i tude modul ati on (QM DSB AM)
Si ngl e si deband ampl i tude modul ati on (SSB AM)
Fr equency modul ati on (FM)
Phase modul ati on (PM)
The tool box al so i ncl udes demodul ati on methods for these modul ati on
i mpl ementati ons.
A l owpass fi l ter pl ays an i mportant rol e i n the demodul ati on of a modul ated
si gnal . I t i s i mportant that the l owpass fi l ter be wel l desi gned. I n thi s tool box,
l owpass fi l ters ar e not provi ded as defaul t par ameters. You must pr ovi de the
numerator and denomi nator of a fi l ter i n a demodul ati on bl ock. However , i f you
do not know whi ch fi l ter to choose, you can use functi ons i n the Si gnal
Processi ng Tool box to fi nd a proper fi l ter for your appl i cati on. A si mpl e
6-112
exampl e of desi gni ng a demodul ati on l owpass fi l ter i s to desi gn a Butterwor th
fi l ter usi ng the command:
[ num, den] = but t e r ( Or d, Fc * 2 * Sampl e _t i me ) ;
where Or d i s the order of the fi l ter ; Fc i s the car ri er fr equency i n the
modul ati on; Sampl e _t i me i s the cal cul ati on sampl i ng ti me; and num and de n are
the numerator and denomi nator of the l owpass fi l ter . Al l of the exampl es i n
thi s tool box use thi s command i n computi ng the l owpass fi l ter.
Demodul ati on pr ocedur es i ntroduce some ti me del ays because of the presence
of l owpass fi l ters i n the demodul ati on pr ocess. The ti me del ay var i es wi th the
fi l ter structure, fi l ter par ameters, and sampl i ng ti me. The tool box does not
provi de the esti mati on of the ti me del ay of the demodul ati on.
6-113
Thi s fi gure shows the Anal og Passband Modul ati on/Demodul ati on Subl i br ary:
Figure 6-11: Analog Passband Modulation/ Demodulation Sublibrary
6-114
Analog Modulation/ Demodulation
Passband Reference Table
Thi s tabl e l i sts the Si mul i nk bl ocks i n the Anal og Mo/Dem Passband
subl i br ary. (They are l i sted al phabeti cal l y i n thi s tabl e for your conveni ence.):
Block Name Description
ADM wi th Car ri er Ampl i tude demodul ati on wi th
carr i er
AM wi th Carr i er Ampl i tude modul ati on wi th car ri er
DSB ADM Doubl e si deband ampl i tude
demodul ati on
DSB-SC AM Doubl e si deband ampl i tude
modul ati on wi th suppressed carr i er
FDM Fr equency demodul ati on
FM Fr equency modul ati on
PDM Phase demodul ati on
PM Phase modul ati on
QADM Quadratur e ampl i tude
demodul ati on
QAM Quadratur e ampl i tude modul ati on
SSB-ADM Si ngl e si deband ampl i tude
demodul ati on
SSB-AM Si ngl e si deband ampl i tude
modul ati on
DSB-SC AM
6-115
6
DSB-SC AM
Catagory Passband modul ati on
Location Anal og Mo/Dem, Passband Subl i brar y
Description The DSB-SC AM (doubl e si deband suppressed-carr i er ampl i tude modul ati on)
bl ock modul ates an i nput si gnal wi th a car ri er frequency si gnal . For any i nput
si gnal , u(t), and car ri er fr equency, f
c
, the r esul ti ng modul ated si gnal , y(t) i s
where A
c
i s an ampl i tude scal e factor and i s the
i ni ti al phase of the modul ati on.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block Costas PLL DSB ADM
Equivalent
M-function commod
y t ( ) A
c
u t ( ) 2f
c
t + ( ) si n =
The car r i er fr equency (Hz). Set thi s to a number
gr eater than the message si gnal fr equency.
The i ni ti al phase (r ad).
The sampl e ti me (sec).
DSB ADM
6-116
DSB ADM
Catagory Passband demodul ati on
Location Anal og Mo/Dem, Passband Subl i br ary
Description The DSB ADM (phase-l ocked l oop doubl e si deband suppressed-carr i er
ampl i tude demodul ati on) bl ock r ecovers a message si gnal fr om i ts modul ated
for m. The DSB ADM method i s shown bel ow:
Figure 6-12: DSB Amplitude Demodulation
(VCO -- vol tage contr ol l ed osci l l ator ).
Lowpass fi l ters pl ay an i mportant r ol e i n the demodul ati on. Refer to chapter 3,
the Tutorial, for i nfor mati on on how to sel ect the numerator and denomi nator
of the l owpass fi l ter transfer functi on.
lowpass
filter
90
shift
5
lowpass
filter
5
5
Input signal
Output
signal
VCO
DSB ADM
6-117
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States 2 * order _of_the_l owpass_fi l ter
Di r ect Feedthrough Yes
Pair Block DSB-SC AM
Equivalent
M-function comde mod
Match the carr i er fr equency (Hz) to the one used
i n the cor respondi ng DSB-SC AM bl ock.
The numer ator of the l owpass fi l ter tr ansfer func-
ti on used i n the demodul ati on.
The denomi nator of the l owpass fi l ter transfer
functi on. For an FI R fi l ter , set thi s par ameter
to 1.
The i ni ti al phase (r ad) of the car r i er si gnal .
Match the sampl e ti me to the one used i n the
cor r espondi ng DSB-SC AM bl ock.
QAM
6-118
QAM
Catagory Passband quadr atur e modul ati on
Location Anal og Mo/Dem, Passband Subl i br ary
Description The QAM (quadrature ampl i tude modul ati on) bl ock combi nes two i ndependent
message si gnal s i nto a si ngl e modul ated si gnal . The two i ndependent message
si gnal s ar e combi ned wi th two carr i er frequenci es that are 90 out of phase
wi th each other . The resul ti ng si gnal components ar e or thogonal , whi ch
si mpl i fi es message si gnal r ecover y on the r ecei vi ng si de. Quadr ature
modul ati on used i n QAM i s shown bel ow:
Figure 6-13: Quadrature Amplitude Demodulation
I nput port 1 accepts the i n-phase si gnal , and i nput port 2 accepts the
quadr ature si gnal .
90
shift
carrier
source
5
5
5
In-phase signal
Quadrature signal
Quadrature-modulated
signal
QAM
6-119
Dialog Box
Characteristics No. of I nputs/Outputs 2/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block QADM
Equivalent
M-function commod
Set the car r i er fr equency to a number greater
than ei ther of the fr equenci es of the two i nput
message si gnal s.
The i ni ti al phase of the car r i er si gnal .
By the Nyqui st sampl i ng theor em,
1/s ampl e_t i me > 2car r i e r _f r e quency .
QADM
6-120
QADM
Catagory Passband quadr atur e demodul ati on
Location Anal og Mo/Dem, Passband Subl i br ary
Description The QMADM (quadr atur e ampl i tude demodul ati on) bl ock recovers a message
si gnal from a quadratur e modul ated carr i er si gnal . Thi s bl ock r ecover s both
the i n-phase and quadr atur e message si gnal s. The fi gure bel ow shows the
demodul ati on process:
Figure 6-14: Quadrature Amplitude Demodulation
Output por t 1 outputs the r ecovered i n-phase si gnal . Output port 2 outputs the
recovered quadratur e si gnal .
Lowpass fi l ters pl ay an i mportant r ol e i n the demodul ati on. Refer to chapter 3,
the Tutorial, for i nfor mati on on how to sel ect the numerator and denomi nator
of the l owpass fi l ter transfer functi on.
90
shift
carrier
recovery
5
5
lowpass
filter
lowpass
filter
In-phase signal
Quadrature signal
Modulated signal
QADM
6-121
Dialog Box
Characteristics No. of I nputs/Outputs 1/2
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States 2 * Or der_of _the_l owpass_fi l ter
Di r ect Feedthrough Yes
Pair Block QAM
Equivalent
M-function comde mod
Match the car ri er frequency (Hz) to that of the
cor r espondi ng QAM bl ock.
The numer ator of the l owpass fi l ter tr ansfer
functi on used i n the demodul ati on.
The denomi nator of the l owpass fi l ter transfer
functi on. For an FI R fi l ter , set thi s par ameter
to 1.
The i ni ti al phase (r ad) of the car r i er si gnal .
Match the sampl e ti me to the one used i n the
cor r espondi ng QAM bl ock.
FM
6-122
FM
Catagory Passband modul ati on
Location Anal og Mo/Dem, Passband Subl i br ary
Description The FM (frequency modul ati on) bl ock modul ates a message si gnal usi ng
frequency modul ati on. I n thi s techni que, the si gnal fr equency var i es wi th the
ampl i tude of the i nput message si gnal . Let u(t) be the i nput message si gnal , A
c

the ampl i tude scal e factor; K
c
the modul ati on sensi ti vi ty constant, and be the
i ni ti al phase. The the output of thi s bl ock i s:
wher e
and f
c
i s the carr i er frequency.
I t i s possi bl e to model FSK (fr equency shi ft keyi ng) i n thi s bl ock by setti ng the
symbol i nterval parameter . Thi s par ameter, when set to a val ue other than I nf,
resets the i ntegr ator i n the above equati on. To model FSK, set the val ue to the
l ength requi red to transmi t an i nfor mati on bi t. Thi s for ces an i ntegr ator r eset
at the onset of each bi t transmi ssi on.
Dialog Box
y t ( ) A
c
2t) + ( ) cos =
t ( ) f
c
t ( ) K
c
u t ( ) t d
0
t

+ =
Set the car r i er fr equency to a number gr eater
than ei ther of the fr equenci es of the two i nput
message si gnal s.
The i ni ti al phase of the car r i er si gnal .
By the Nyqui st sampl i ng theor em, 1/
s ampl e _t i me > 2car r i e r _f r eque nc y .
For anal og modul ati on, set thi s par ameter to I nf.
For FSK model i ng, set i t to the l ength of ti me
r equi red to tr ansmi t a si ngl e i nformati on bi t.
FM
6-123
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States 1
Di r ect Feedthrough No
Pair Block FDM
Equivalent
M-function commod
FDM
6-124
FDM
Catagory Passband demodul ati on
Location Anal og Mo/Dem, Passband Subl i br ary
Description The FDM (fr equency demodul ati on) bl ock recovers a message si gnal from a
frequency modul ated carr i er si gnal .
Lowpass fi l ters pl ay an i mportant r ol e i n the demodul ati on. Refer to chapter 3,
the Tutorial, for i nfor mati on on how to sel ect the numerator and denomi nator
of the l owpass fi l ter transfer functi on.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States Or der _of_the_l owpass_fi l ter + 1
Di r ect Feedthrough Yes
Pair Block FM
Equivalent
M-function
comdemod
Match the carr i er frequency to that of the cor r e-
spondi ng FM bl ock.
VCO i ni ti al phase (rad).
The numer ator of the l owpass fi l ter tr ansfer
functi on used i n the demodul ati on.
The denomi nator of the l owpass fi l ter transfer
functi on. For an FI R fi l ter , set thi s par ameter
to 1.
Match the sampl e ti me to that of the
cor r espondi ng FM bl ock.
PM
6-125
PM
Catagory Passband modul ati on
Location Anal og Mo/Dem, Passband Subl i brar y
Description The PM (phase modul ati on) bl ock converts an i nput message si gnal i nto a
modul ated si gnal usi ng phase modul ati on. I n thi s techni que, the phase of the
carr i er fr equency i s var i ed i n pr opor ti on to the ampl i tude of the i ncomi ng
message si gnal . Let u(t) be the i nput message si gnal , A
c
be the ampl i tude scal e
factor , and be the i ni ti al phase. The output of thi s bl ock i s:
where
and f
c
i s the carr i er frequency. I f the i nput si gnal i s not conti nuous, the
modul ated output si gnal may be di sconti nuous.
Dialog Box
y t ( ) A
c
2 t ( ) + ( ) cos =
t ( ) f
c
t ( ) u t ( ) + =
The car ri er frequency must be gr eater than the
fr equency bandwi dth of ei ther of the i nput
message si gnal s.
The i ni ti al phase of the car r i er si gnal .
For anal og modul ati on, set thi s parameter to I nf.
PM
6-126
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Auto
States N/A
Di r ect Feedthrough Yes
Pair Block PLL PDM
Equivalent
M-function commod
PDM
6-127
PDM
Catagory Passband demodul ati on
Location Anal og Mo/Dem, Passband Subl i brar y
Description The PDM (phase demodul ati on) bl ock recovers a message si gnal from a
phase-modul ated carr i er si gnal .
Lowpass fi l ters pl ay an i mportant r ol e i n the demodul ati on. Refer to chapter 3,
the Tutorial, for i nfor mati on on how to sel ect the numerator and denomi nator
of the l owpass fi l ter tr ansfer functi on.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States Or der_of_the_l owpass_fi l ter + 2
Di r ect Feedthrough Yes
Pair Block PM
Equivalent
M-function comde mod
Match the car ri er frequency to that of the corr e-
spondi ng PM bl ock.
The i ni ti al phase of the car r i er fr equency.
The numer ator of the l owpass fi l ter tr ansfer
functi on used i n the demodul ati on.
The denomi nator of the l owpass fi l ter transfer
functi on. For an FI R fi l ter , set thi s par ameter
to 1.
By the Nyqui st sampl i ng theor em,
1/s ampl e_t i me > 2car r i e r _f r e quency .
SSB-AM
6-128
SSB-AM
Catagory Passband modul ati on
Location Anal og Mo/Dem, Passband Subl i br ary
Description The SSB-AM (si ngl e si deband ampl i tude modul ati on) bl ock modul ates an
i nput si gnal wi th a gi ven car ri er fr equency usi ng SSB-AM wi th a Hi l bert fi l ter.
For detai l s on Hi l ber t transforms, refer to Chapter 3, the Tutorial.
SSB-AM tr ansmi ts ei ther the l ower or upper si deband si gnal , but not both as
i s the case i s DSB-AM.
Set the bandwi dth of the i nput si gnal par ameter to the esti mated hi ghest
frequency component i n the i nput message si gnal . Thi s i s used to desi gn a
compensator wi th the Hi l ber t fi l ter . Thi s for ces the message si gnal ampl i tude
to r emai n wi thi n the assi gned r ange. I f assi gned to 0 or a val ue l arger than 1/
(2*sampl e_ti me), the bl ock does not generate a compensator.
Thi s bl ock requi res a ti me del ay for the Hi l ber t fi l ter. Set thi s parameter to
( N+0. 5) s ampl e _t i me
wher e N i s a posi ti ve i nteger . Thi s bl ock uses the functi on hi l bi i r to desi gn
the Hi l bert fi l ter .
Dialog Box
The car r i er si gnal (Hz) must be gr eater than the
fr equency bandwi dth of the i nput si gnal .
The i ni ti al phase (r ad) of the car r i er fr equency.
Set the bandwi dth of the i nput si gnal to 0 for no
compensati on. Other wi se, set i t to the hi ghest
fr equency component of the message si gnal .
Set the ti me del ay to (N + 0.5) * Sampl e_ti me,
where N i s a posi ti ve i nteger .
Speci fy the sampl e ti me.
Speci fy whether to use the upper or l ower
si deband.
SSB-AM
6-129
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States cei l (Ti me_del ay/Sampl e_ti me) + 5
Di r ect Feedthrough Yes
Pair Block SSB ADM
Equivalent
M-function commod
SSB ADM
6-130
SSB ADM
Catagory Passband demodul ati on
Location Anal og Mo/Dem, Passband Subl i br ary
Description The SSB ADM (si ngl e si deband ampl i tude demodul ati on) r ecover s a message
si gnal from a si gnal modul ated usi ng the SSB AM techni que.
Lowpass fi l ters pl ay an i mportant r ol e i n the demodul ati on. Refer to chapter 3,
the Tutorial, for i nfor mati on on how to sel ect the numerator and denomi nator
of the l owpass fi l ter transfer functi on.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States Or der _of_the_l owpass_fi l ter
Di r ect Feedthrough Yes
Pair Block SSB AM
Equivalent
M-function comdemod
Match the carr i er frequency to that of the
cor r espondi ng SSB AM bl ock.
The numer ator of the l owpass fi l ter tr ansfer
functi on used i n the demodul ati on.
The denomi nator of the l owpass fi l ter transfer
functi on. For an FI R fi l ter , set thi s par ameter
to 1.
The i ni ti al phase of the car r i er fr equency.
Match the sampl e ti me to that of the
cor r espondi ng SSB AM bl ock.
AM With Carrier
6-131
AM Wi th Carr i er
Catagory Passband modul ati on
Location Anal og Mo/Dem, Passband Subl i brar y
Description The AM Wi th Carr i er bl ock modul ates the i nput si gnal wi th a gi ven carr i er
frequency usi ng the ampl i tude modul ati on wi th carr i er techni que. I n thi s
method, the modul ated output si gnal i s gi ven by
where y(t) i s the output si gnal , u(t) the i nput si gnal to be modul ated, f
c
i s the
carr i er fr equency, and k an offset val ue that i s added to the si gnal i n thi s
modul ati on techni que. I t i s common to set the val ue of k to the maxi mum
absol ute val ue of the negati ve part of the i nput si gnal u(t). The output si gnal i s
si nusoi dal wi th i ts envel ope havi ng the shape of the i nput si gnal .
Dialog Box
y t ( ) u t ( ) k + ( ) 2f
c
t ( ) si n =
The offset factor i n the above AM equati on. Thi s
val ue shoul d be l ar ger than or equal to the abso-
l ute val ue of the mi ni mum val ue of the message
si gnal u(t).
The car ri er frequency must be gr eater than the
fr equency bandwi dth of ei ther of the i nput
message si gnal s.
The i ni ti al phase of the car r i er si gnal .
By the Nyqui st sampl i ng theor em,
1/s ampl e_t i me > 2car r i e r _f r e quency .
AM With Carrier
6-132
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block ADM wi th Car ri er
Equivalent
M-function commod
ADM with Carrier
6-133
ADM wi th Carri er
Catagory Passband demodul ati on
Location Anal og Mo/Dem, Passband Subl i brar y
Description The ADM wi th Carr i er bl ock recover s a message si gnal from an AM wi th
carr i er modul ated si gnal usi ng the envel ope detecti on method. The par ameters
set i n thi s bl ock must match those used i n the AM Wi th Carr i er bl ock.
Lowpass fi l ters pl ay an i mportant r ol e i n the demodul ati on. Refer to chapter 3,
the Tutorial, for i nfor mati on on how to sel ect the numerator and denomi nator
of the l owpass fi l ter tr ansfer functi on.
Dialog Block
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States 2 * Or der_of_the_l owpass_fi l ter
Di r ect Feedthrough Yes
Pair Block AM wi th Carr i er
Equivalent
M-function comde mod
Match the offset factor and the carr i er fr equency
to those i n the cor respondi ng AM wi th Car r i er
bl ock.
The i ni ti al phase of the car r i er fr equency.
The numer ator of the l owpass fi l ter tr ansfer
functi on used i n the demodul ati on.
The denomi nator of the l owpass fi l ter transfer
functi on. For an FI R fi l ter , set thi s par ameter
to 1.
By the Nyqui st sampl i ng theor em,
1/s ampl e_t i me > 2car r i e r _f r e quency .
6-134
6
Analog Modulation/ Demodulation
Methods for Baseband Simulation
Pri or to usi ng the bl ocks i n thi s secti on, you shoul d r ead thr ough the Baseband
Si mul ati on secti on i n chapter 3, the Tutorial.
A modul ati on bl ock i n baseband si mul ati on takes a real si gnal and outputs a
compl ex si gnal . A demodul ati on bl ock i n baseband si mul ati on takes a compl ex
si gnal and outputs a real si gnal . I n the Si mul i nk bl ock l i brar y of thi s tool box,
a compl ex number i s repr esented by a l ength two vector wi th the fi r st el ement
bei ng the r eal part and the second el ement bei ng the i mage part of a compl ex
number.
The baseband bl ock l i br ar y i s anal ogous to the passband si mul ati on. For every
modul ati on/demodul ati on bl ock i n baseband, you can fi nd a passband
counter part i n the passband and vi ce versa. The si mul ati on resul ts of these two
techni ques shoul d be ver y cl ose to each other . The advantage of usi ng the
baseband si mul ati on i s that the speed for baseband si mul ati on can be much
faster than the passband si mul ati on si nce the sampl e frequency for passband
si mul ati on must be at l east twi ce as the carr i er frequency. There i s no such
l i mi t for the baseband si mul ati on.
To match the r esul t between the baseband and passband si mul ati on, thi s
tool box uses l owpass fi l ter s i n the baseband si mul ati on. Note that the sampl i ng
frequency for the passband si mul ati on may be di fferent fr om the sampl i ng
frequency for the baseband si mul ati on. To obtai n a si mi l ar feature of a fi l ter
under a di ffer ent sampl i ng ti me, use the functi ons c2dm and d2c m i n the Contr ol
System Tool box to convert the fi l ters fr om one sampl e frequency to another, for
exampl e, i f your fi l ter has the numerator, num1, and denomi nator, den1, at the
sampl i ng ti me t s 1. To get a fi l ter wi th the same fr equency response at
sampl i ng ti me t s 2, you can use the fol l owi ng commands to do the conversi on.
[ num, den] = d2c m( num1, den1, t s 1) ;
[ num2, de n2] = c 2dm( num, de n, t s 2) ;
The resul ti ng new fi l ter has numerator num2, denomi nator de n2, and sampl i ng
ti me t s 2. The numer ator num2 and denomi nator de n2 wi th sampl i ng ti me t s 2
have the si mi l ar frequency r esponse as the pai r num1 and de n1 wi th sampl i ng
ti me t s 1.
6-135
The car ri er frequency i s no l onger needed as a par ameter i n the baseband
modul ati on/demodul ati on si mul ati on. I f you dont car e about the del ay factor s,
you can di rectl y assi gn both numerator and denomi nator of the fi l ter to be 1.
Thi s fi gur e shows the Anal og Modul ati on/Demodul ati on, Baseband Subl i brary:
Figure 6-15: Analog Modulation/ Demodulation, Baseband Sublibrary
6-136
Analog Modulation/ Demodulation
Baseband Reference Table
Thi s tabl e l i sts the Si mul i nk bl ocks i n the Anal og Modul ati on/Demodul ati on
Baseband Subl i brar y. (Thi s tabl e l i sts the bl ocks i n al phabeti cal or der for your
conveni ence.):
Block Name Description
ADM wi th Car ri er CE Ampl i tude demodul ati on
wi th car ri er
AM wi th Carr i er CC Ampl i tude modul ati on wi th car ri er
DSB ADM CE Doubl e si deband ampl i tude
demodul ati on
DSB-SC AM CE Doubl e si deband ampl i tude
modul ati on wi th suppressed carr i er
FDM CE Fr equency demodul ati on
FM CE Fr equency modul ati on
PDM CE Phase demodul ati on
PM CE Phase modul ati on
QADM CE Quadratur e ampl i tude
demodul ati on
QAM CE Quadratur e ampl i tude modul ati on
SSB-ADM CE Si ngl e si deband ampl i tude
demodul ati on
SSB-AM CE Si ngl e si deband ampl i tude
modul ati on
DSB-SC AM CE
6-137
6
DSB-SC AM CE
Catagory Baseband modul ati on
Location Anal og Mo/Dem, Baseband Subl i br ary
Description The DSB-SC AM CE (doubl e si deband-suppressed car ri er ampl i tude
modul ati on compl ex envel ope) bl ock modul ates an i nput si gnal wi th a car ri er
frequency. The i nput si gnal , u(t), i s a real si gnal . The output si gnal , y(t), i s a
compl ex si gnal represented by a l ength 2 vector. The fi rst i ndex i s the real part
of the modul ated si gnal , the second i ndex i s the compl ex part. The output of
thi s bl ock i s:
where i s the phase shi ft of the si gnal .
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/Yes
Ti me Base Auto
States N/A
Di r ect Feedthrough Yes
Pair Block DSB ADM CE
Equivalent
M-function amodc e
y t ( ) u t ( )e
j
=
The i ni ti al phase of the car r i er fr equency.
DSB ADM CE
6-138
DSB ADM CE
Catagory Baseband demodul ati on
Location Anal og Mo/Dem, Baseband Subl i br ary
Description The DSB ADM CE (ampl i tude demodul ati on compl ex envel ope) bl ock recovers
a message si gnal from the i nput modul ated si gnal . The i nput to thi s bl ock i s a
compl ex si gnal , represented i n Si mul i nk as a l ength 2 vector. The fi r st el ement
i s the real par t of the si gnal , and the second i s the i magi nary part. The output
of thi s bl ock i s the recover ed si gnal , whi ch i s a real scal ar .
Lowpass fi l ters pl ay an i mportant r ol e i n demodul ati on. Refer to chapter 3, the
Tutorial, for i nfor mati on on how to sel ect the numer ator and denomi nator of
the l owpass fi l ter transfer functi on.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs Yes/No
Ti me Base Di scr ete ti me
States 2 * order_of_the_l owpass_fi l ter
Di r ect Feedthrough Yes
Pair Block DSB-SC AM
Equivalent
M-function ademodc e
The numer ator of the l owpass fi l ter tr ansfer
functi on used i n the demodul ati on.
The denomi nator of the l owpass fi l ter transfer
functi on. For an FI R fi l ter , set thi s par ameter
to 1.
The i ni ti al phase of the car r i er fr equency.
Match the sampl e ti me to that of the
cor r espondi ng DSB-SC AM bl ock.
QAM CE
6-139
QAM CE
Catagory Baseband modul ati on
Location Anal og Mo/Dem, Baseband Subl i br ary
Description The QAM CE (quadr atur e ampl i tude modul ati on compl ex envel ope) bl ock
modul ates two i ndependent i nput si gnal s wi th a si ngl e carr i er fr equency
si gnal . The two i nput si gnal s ar e r eal , and the output modul ated si gnal i s
compl ex. Si mul i nk r epresents compl ex numbers as l ength 2 vector s. The fi rst
el ement i s the r eal part of the si gnal , and the second el ement i s the i magi nary
part. The mathemati cal oper ati on i n thi s bl ock i s:
where y(t) i s the compl ex output si gnal , u
1
(t) and u
2
(t) are the real i nput
si gnal s, and i s the phase shi ft of the carr i er frequency.
I nput por t 1 accepts an i n-phase si gnal u
1
(t) and i nput por t 2 accepts a
quadrature si gnal u
2
(t). The output por t outputs y(t), the compl ex envel ope of
the modul ated si gnal .
Dialog Box
Characteristics No. of I nputs/Outputs 2/1
Vector i zed I nputs/Outputs No/Yes
Ti me Base Auto
States N/A
Di r ect Feedthrough Yes
Pair Block QADM CE
Equivalent
M-function amodc e
y t ( ) u
1
t ( ) u
2
t ( ) + ( ) = e
j
The i ni ti al phase i n the carr i er si gnal .
QADM CE
6-140
QADM CE
Catagory Baseband demodul ati on
Location Anal og Mo/Dem, Baseband Subl i br ary
Description The QADM CE (quadr atur e ampl i tude demodul ati on compl ex envel ope) bl ock
recovers a message si gnal fr om a modul ated i nput si gnal . Thi s bl ock accepts a
compl ex si gnal and outputs a two-part r ecover ed message si gnal . The fi r st
si gnal i s i n-phase part of the message si gnal , and the second i s the quadr ature
part.
The i nput port accepts the compl ex modul ated si gnal . Output 1 outputs the
i n-phase par t of the message si gnal , and output por t 2 outputs the quadratur e
part.
Lowpass fi l ters pl ay an i mportant r ol e i n demodul ati on. Refer to chapter 3, the
Tutorial, for i nfor mati on on how to sel ect the numer ator and denomi nator of
the l owpass fi l ter transfer functi on.
Dialog Box
The numer ator of the l owpass fi l ter tr ansfer func-
ti on used i n the demodul ati on.
The denomi nator of the l owpass fi l ter transfer
functi on. For an FI R fi l ter , set thi s par ameter
to 1.
The i ni ti al phase of the car r i er fr equency.
By the Nyqui st sampl i ng theor em,
1/sampl e_ti me > 2 * car r i er _fr equency.
QADM CE
6-141
Characteristics No. of I nputs/Outputs 1/2
Vector i zed I nputs/Outputs Yes/No
Ti me Base Di scr ete ti me
States 2 * order _of_the_l owpass_fi l ter
Di r ect Feedthrough Yes
Pair Block QM DSB AM CE
Equivalent
M-function ade modc e
FM CE
6-142
FM CE
Catagory Baseband modul ati on
Location Anal og Mo/Dem, Baseband Subl i br ary
Description The FM CE (fr equency modul ati on compl ex envel ope) bl ock modul ates a
message si gnal usi ng the fr equency modul ati on techni que. I n FM, the
ampl i tude of the i nput si gnal di r ectl y affects the fr equency of the modul ated
si gnal .
The i nput to thi s bl ock i s a r eal si gnal . The output si gnal i s a compl ex number,
whi ch i s the compl ex envel ope of the frequency modul ati on of the i nput si gnal .
The mathemati cal rel ati onshi p between the i nput and output si gnal s i s:
wher e u(t) i s the i nput si gnal , y(t) the output si gnal , and the phase-shi ft i n
the modul ati on.
The compl ex output i s repr esented by a l ength 2 vector. The fi rst el ement i s the
real part of the si gnal , and the second el ement i s the i magi nary par t.
I t i s possi bl e to model FSK (fr equency shi ft keyi ng) i n thi s bl ock by setti ng the
symbol interval parameter . Thi s par ameter, when set to a val ue other than I nf,
resets the i ntegr ator i n the above equati on. To model FSK, set the val ue to the
l ength requi red to transmi t an i nfor mati on bi t. Thi s for ces an i ntegr ator r eset
at the onset of each bi t transmi ssi on.
y t ( ) e
j u ( ) d
0
t

+
,

_
=
FM CE
6-143
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs Yes/No
Ti me Base Di scr ete ti me
States 1
Di r ect Feedthrough No
Pair Block FDM CE
Equivalent
M-function amodc e
The i ni ti al phase of the car r i er si gnal .
By the Nyqui st sampl i ng theor em, 1/
s ampl e_t i me > 2car r i e r _f r e quency .
For anal og modul ati on, set thi s par ameter
to I nf. For FSK model i ng, set i t to the
l ength of ti me r equi r ed to tr ansmi t a si ngl e
i nformati on bi t.
FDM CE
6-144
FDM CE
Catagory Baseband demodul ati on
Location Anal og Mo/Dem, Baseband Subl i br ary
Description The PLL FDM CE (phase-l ocked l oop frequency demodul ati on compl ex
envel ope) bl ock recovers a message si gnal from a modul ated i nput si gnal . The
i nput si gnal to thi s bl ock i s compl ex, and thi s bl ock r epr esents compl ex si gnal s
as l ength 2 vector s. The fi rst el ement i s the r eal par t of the si gnal , and the
second i s the i magi nar y part.
Lowpass fi l ters pl ay an i mportant r ol e i n demodul ati on. Refer to chapter 3, the
Tutorial, for i nfor mati on on how to sel ect the numer ator and denomi nator of
the l owpass fi l ter transfer functi on.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States Or der _of_the_l owpass_fi l ter + 1
Di r ect Feedthrough No
Pair Block FM CE
Equivalent
M-function ademodc e
The i ni ti al phase of the car r i er si gnal .
The numer ator of the l owpass fi l ter tr ansfer
functi on used i n the demodul ati on.
The denomi nator of the l owpass fi l ter transfer
functi on. For an FI R fi l ter , set thi s par ameter
to 1.
By the Nyqui st sampl i ng theor em, 1/
s ampl e _t i me > 2c ar r i er _f r eque nc y.
PM CE
6-145
PM CE
Catagory Baseband modul ati on
Location Anal og Mo/Dem, Baseband Subl i br ary
Description The PM CE (phase modul ati on compl ex envel ope) bl ock modul ates an i nput
message si gnal usi ng phase modul ati on techni que. The i nput to thi s bl ock i s a
real si gnal . The output i s a compl ex number repr esented by a l ength 2 vector.
The fi rst el ement i s the real par t of the si gnal , and the second i s the i magi nar y
part. Thi s compl ex number i s the compl ex envel ope of the phase modul ati on.
The mathemati cal rel ati onshi p between the i nput, u(t), and the output, y(t), i s:
where i s the phase shi ft i n the modul ati on.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/Yes
Ti me Base Auto
States N/A
Di r ect Feedthrough Yes
Pair Block PDM CE
Equivalent
M-function amodc e
y t ( ) e
j u t ( ) + ( )
=
The i ni ti al phase of the car r i er fr equency.
PDM CE
6-146
PDM CE
Catagory Baseband demodul ati on
Location Anal og Mo/Dem, Baseband Subl i br ary
Description The PM CE (phase modul ati on compl ex envel ope) bl ock recovers a message
si gnal from a modul ated i nput si gnal . The i nput to thi s bl ock i s a compl ex
si gnal . The output i s the recover ed r eal si gnal .
Lowpass fi l ters pl ay an i mportant r ol e i n demodul ati on. Refer to chapter 3, the
Tutorial, for i nfor mati on on how to sel ect the numer ator and denomi nator of
the l owpass fi l ter transfer functi on.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs Yes/No
Ti me Base Di scr ete ti me
States Or der _of_the_l owpass_fi l ter + 2
Di r ect Feedthrough No
Pair Block PM CE
Equivalent
M-function ademodc e
The i ni ti al phase of the car r i er si gnal .
The numer ator of the l owpass fi l ter tr ansfer
functi on used i n the demodul ati on.
The denomi nator of the l owpass fi l ter transfer
functi on. For an FI R fi l ter , set thi s par ameter
to 1.
By the Nyqui st sampl i ng theor em,
1/s ampl e _t i me > 2car r i e r _f r eque ncy .
SSB-AM CE
6-147
SSB-AM CE
Catagory Baseband modul ati on
Location Anal og Mo/Dem, Baseband Subl i br ary
Description The SSB-AM CE (si ngl e si deband-ampl i tude modul ati on compl ex envel ope)
bl ock modul ates an i nput message si gnal usi ng ampl i tude modul ati on wi th a
Hi l bert fi l ter . The si ngl e si deband method r equi r es the transmi ssi on of ei ther
the l ower or upper si deband si gnal , but not both. Thi s l i mi tati on means that i t
i s not possi bl e to transmi t a DC component of the si gnal . For detai l s on thi s
method, and on Hi l ber t transforms, refer to chapter 3, the Tutorial.
The i nput to thi s bl ock i s a r eal si gnal . The output i s a compl ex si gnal . Si mul i nk
repr esents a compl ex number by a l ength 2 vector. The fi rst el ement i s the real
part of the si gnal , and the second el ement i s the i magi nary par t. The
mathemati cal r el ati onshi p between the i nput, u(t), and the output, y(t), i s:
where i s the phase shi ft of the si gnal and (t) i s the Hi l ber t tr ansfor m of the
i nput u(t).
Dialog Box
y t ( ) u t ( ) ju t ( ) + ( )e
j
=
The i ni ti al phase (r ad) of the car r i er fr equency.
Set the bandwi dth of the i nput si gnal to 0 for no
compensati on. Other wi se, set i t to the hi ghest
fr equency component of the message si gnal .
Set the ti me del ay to (N + 0. 5) Sampl e _t i me,
wher e N i s a posi ti ve i nteger .
The sampl e ti me of the cal cul ati on.
Speci fy whether to use the upper or l ower
si deband.
SSB-AM CE
6-148
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/Yes
Ti me Base Di scr ete ti me
States cei l (ti me_del ay/sampl e_ti me) +5
Di r ect Feedthrough Yes
Pair Block SSB ADM
Equivalent
M-function amodce
SSB ADM CE
6-149
SSB ADM CE
Catagory Baseband demodul ati on
Location Anal og Mo/Dem, Baseband Subl i br ary
Description The SSB ADM (si ngl e si deband ampl i tude demodul ati on) bl ock r ecover s a
message si gnal fr om a modul ated i nput si gnal . The i nput to thi s bl ock i s a
compl ex si gnal r epr esented by a l ength 2 vector. The fi r st el ement i s the real
part of the si gnal , and the second i s the i magi nary par t. The output of thi s bl ock
i s a real si gnal .
Lowpass fi l ters pl ay an i mportant rol e i n demodul ati on. Refer to chapter 3, the
Tutorial, for i nformati on on how to sel ect the numer ator and denomi nator of
the l owpass fi l ter transfer functi on.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs Yes/No
Ti me Base Di scr ete ti me
States Or der_of_the_l owpass_fi l ter
Di r ect Feedthrough Yes
Pair Block SSB AM CE
Equivalent
M-function ade modc e
The numer ator of the l owpass fi l ter tr ansfer
functi on used i n the demodul ati on.
The denomi nator of the l owpass fi l ter transfer
functi on. For an FI R fi l ter , set thi s par ameter
to 1.
The i ni ti al phase of the car r i er si gnal .
By the Nyqui st sampl i ng theor em,
1/sampl e_ti me > 2 * carr i er _fr equency.
AM With Carrier CE
6-150
AM Wi th Carr i er CE
Catagory Baseband modul ati on
Location Anal og Mo/Dem, Baseband Subl i br ary
Description The AM wi th Car ri er CE (ampl i tude modul ati on wi th car ri er compl ex
envel ope) bl ock modul ates an i nput message si gnal usi ng ampl i tude
modul ati on. The i nput to thi s bl ock i s a r eal si gnal , and the output i s a compl ex
si gnal . Si mul i nk r epr esents a compl ex number by a l ength 2 vector . The fi rst
el ement i s the real part, and the second i s the i magi nary par t. The
mathemati cal r el ati onshi p between the i nput, u(t), and the output, y(t,) i s:
wher e q i s the phase shi ft of the si gnal and k i s the i ni ti al si gnal offset.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs Yes/No
Ti me Base Auto
States N/A
Di r ect Feedthrough Yes
Pair Block ADM CE wi th Carr i er
Equivalent
M-function amodce
y t ( ) u t ( ) k + ( )e
j
=
The offset factor i n the above AM equati on.
Thi s val ue shoul d be l ar ger than or equal to the
absol ute val ue of the mi ni mum val ue of the
message si gnal u(t).
The i ni ti al phase of the car r i er si gnal .
ADM with Carrier CE
6-151
ADM wi th Carri er CE
Catagory Baseband demodul ati on
Location Anal og Mo/Dem, Baseband Subl i br ary
Description The ADM CE wi th Carr i er (ampl i tude demodul ati on compl ex envel ope wi th
carr i er ) bl ock r ecover s a message si gnal fr om a modul ated i nput si gnal . The
i nput to thi s bl ock i s a compl ex si gnal . Si mul i nk r epr esents compl ex numbers
by l ength 2 vector s. The fi rst el ement of the vector i s the r eal part of the
compl ex si gnal , and the second el ement i s the i magi nar y par t. The output i s a
real si gnal .
Lowpass fi l ters pl ay an i mportant rol e i n demodul ati on. Refer to chapter 3, the
Tutorial, for i nformati on on how to sel ect the numer ator and denomi nator of
the l owpass fi l ter transfer functi on.
Dialog Box
Match the offset fact to the val ue used i n the
cor r espondi ng AM wi th Carr i er CE bl ock.
The numer ator of the l owpass fi l ter tr ansfer
functi on used i n the demodul ati on.
The denomi nator of the l owpass fi l ter transfer
functi on. For an FI R fi l ter , set thi s par ameter
to 1.
The i ni ti al phase of the car r i er si gnal .
By the Nyqui st sampl i ng theor em,
1/s ampl e_t i me > 2c ar r i e r _f r eque nc y.
ADM with Carrier CE
6-152
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs Yes/No
Ti me Base Di scr ete ti me
States 2 * order_of_the_l owpass_fi l ter
Di r ect Feedthrough Yes
Pair Block AM Wi th Car ri er CE
Equivalent
M-Function ademodc e
6-153
6
Digital Modulation/ Demodulation
Methods for Passband Simulation
A di gi tal modul ati on bl ock i s the combi nati on of a mappi ng bl ock and an anal og
modul ati on bl ock. A di gi tal demodul ati on bl ock i s the combi nati on of an anal og
demodul ati on bl ock and a demappi ng bl ock. The di gi tal mappi ng/demappi ng
and modul ati on/demodul ati on bl ocks ar e di scussed separ atel y i n the
Passband Di gi tal Modul ati on/Demodul ati on subl i br ary secti on. The bl ocks i n
thi s Di gi tal Modul ati on/Demodul ati on subl i brary combi ne the mappi ng and
modul ati on functi ons to make r eady-to-use di gi tal modul ati on and
demodul ati on bl ocks.
Thi s subl i brary uses a defaul t Butter worth l owpass fi l ter i n MASK and QASK
demodul ati on bl ocks. The defaul t fi l ter i s desi gned by usi ng the MATLAB
command:
[ num, de n] = but t er ( Or d, Fc 2Sampl e_t i me )
where Or d i s the or der of the fi l ter , Fc i s the car ri er fr equency i n the
modul ati on, Sampl e _t i me i s the cal cul ati on sampl i ng ti me, and num and de n are
the numerator and denomi nator of the l owpass fi l ter . I n thi s subl i brar y, the
defaul t l owpass fi l ter has order 5. I f you pr efer to use your own fi l ter, use
separ ate demappi ng and demodul ati on bl ocks from the Passband Di gi tal
Modul ati on/Demodul ati on subl i br ary, wher e you can customi ze your own
l owpass fi l ters.
6-154
The fi gur e bel ow shows the Di gi tal Mod/Demod Mappi ng/Demappi ng
Passband Subl i brary:
Figure 6-16: Digital Modulation/ Demodulation Passband Sublibrary
6-155
Digital Modulation/ Demodulation
Passband Reference Table
Thi s tabl e l i sts the Si mul i nk bl ocks i n the Di gi tal Modul ati on/Demodul ati on
Passband Subl i br ary. (Thi s tabl e l i sts the bl ocks i n al phabeti cal or der for your
conveni ence.):
Block Name Description
Coher ent MFSK Demod Coher ent mul ti pl e frequency shi ft-keyi ng
(MFSK) demodul ati on fol l owed by mi n/max
demappi ng
MASK Demod Doubl e si deband suppr essed carr i er
ampl i tude demodul ati on (DSB-SC ADM)
fol l owed by mul ti pl e ampl i tude shi ft-keyi ng
(MASK) demappi ng
MASK Mod M-ar y ampl i tude shi ft-keyi ng (MFSK)
mappi ng fol l owed by doubl e si deband
suppr essed carr i er ampl i tude (DSB-SC AM)
modul ati on
MFSK Mod Mul ti pl e fr equency shi ft-keyi ng (MFSK)
mappi ng fol l owed by frequency modul ati on
(FM)
MPSK Mod Mul ti pl e phase shi ft-keyi ng (MPSK)
mappi ng fol l owed by phase modul ati on
MPSK Demod Coher ent mul ti pl e phase shi ft-keyi ng
(MPSK) cor rel ati on demodul ati on fol l owed
by mi n/max demappi ng
Noncoherent MFSK Demod Noncoherent mul ti pl e fr equency
shi ft-keyi ng (MFSK) demodul ati on fol l owed
by mi n/max demappi ng
6-156
QASK Demod Ar bi tr ary
Constel l ati on
Quadratur e ampl i tude demodul ati on
(QADM) fol l owed by quadrature ampl i tude
shi ft-keyi ng (QASK) demappi ng usi ng an
ar bi tr ary constel l ati on
QASK Demod Ci r cl e
Constel l ati on
Quadratur e ampl i tude demodul ati on
(QADM) fol l owed by quadrature ampl i tude
shi ft-keyi ng (QASK) demappi ng usi ng a
ci rcl e constel l ati on
QASK Demod Squar e
Constel l ati on
Quadratur e ampl i tude demodul ati on
(QADM) wi th quadratur e shi ft-keyi ng
(QASK) demappi ng usi ng a square
constel l ati on
QASK Mod Ar bi tr ary
Constel l ati on
Quadratur e ampl i tude shi ft-keyi ng
mappi ng usi ng an ar bi trary constel l ati on
fol l owed by quadr atur e ampl i tude
modul ati on (QAM)
QASK Mod Ci r cl e
Constel l ati on
Quadratur e ampl i tude shi ft-keyi ng
mappi ng usi ng a ci r cl e constel l ati on
fol l owed by quadr atur e ampl i tude
modul ati on (QAM)
QASK Mod Squar e
Constel l ati on
Quadratur e ampl i tude shi ft-keyi ng
mappi ng usi ng a squar e constel l ati on
fol l owed by quadr atur e ampl i tude
modul ati on (QAM)
Block Name Description
MASK Mod
6-157
6
MASK Mod
Catagory Passband Mappi ng/Modul ati on
Location Di gi tal Mo/Dem, Passband Subl i brary
Description The MASK (mul ti pl e ampl i tude shi ft-keyi ng) Mod bl ock maps an i nput si gnal
and then modul ates the mapped si gnal . Thi s bl ock i s a combi nati on of the
MASK Map and DSB-SC AM bl ocks. Refer to the i ndi vi dual r efer ence pages for
these bl ocks for di scussi ons of the techni ques i nvol ved.
MASK Mod i s a passband si mul ati on bl ock. Ther e ar e thr ee ti mi ng var i abl es
i n thi s bl ock: durati on of di gi t (T
d
), car ri er frequency (f
c
), and sampl e ti me (T
s
).
You must sel ect val ues for these var i abl es so that they sati sfy the
mathemati cal r el ati ons bel ow:
Td > 1/f c > 2Ts
Thi s bl ock accepts a scal ar i nput i n the r ange [0, M-1], where M i s the mul ti pl e
number. Typi cal l y, M equal s 2
K
, wher e K i s a posi ti ve i nteger. The output of
thi s bl ock i s a modul ated anal og si gnal wi th a maxi mum ampl i tude equal to
one.
Dialog Box
Speci fy the i nput di gi t r ange, [0, M-1].
The sampl e ti me of the i nput di gi t. When thi s
parameter i s a two-el ement vector , the second
el ement i s the offset val ue.
The frequency of the car r i er si gnal .
The i ni ti al phase of the car r i er si gnal .
The cal cul ati on sampl e ti me. By the
Nyqui st sampl i ng theor em,
1/s ampl e_t i me > 2car r i e r _f r e quency .
MASK Mod
6-158
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block MASK Demod
Equivalent
M-function
dmod
MASK Demod
6-159
MASK Demod
Catagory Passband Demodul ati on/Demappi ng
Location Di gi tal Mo/Dem, Passband Subl i brary
Description The MASK Demod bl ock recover s a message si gnal from a modul ated and
mapped i nput si gnal . Thi s bl ock i s a combi nati on of the Costas PLL DSB ADM
and the MASK Demap bl ocks. Refer to the reference pages for these bl ocks for
di scussi ons of the techni ques i nvol ved.
Thi s bl ock uses a defaul t 5th or der Butter wor th fi l ter, whi ch i t gener ates by
usi ng the command:
[ num, de n] = but t er ( 5, Fc *2*Ts ) ;
The i nput to thi s bl ock i s an anal og modul ated si gnal wi th a maxi mum
ampl i tude equal to one. I t outputs i ntegers i n the r ange [0, M-1], wher e M i s
the mul ti pl e number .
Dialog Box
Match these par ameter s to the ones used i n the
cor r espondi ng MASK Mod bl ock.
The i ni ti al phase of the car r i er si gnal .
The cal cul ati on sampl e ti me. By the
Nyqui st sampl i ng theor em,
1/s ampl e_t i me > 2car r i e r _f r e quency .
MASK Demod
6-160
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/Yes
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block MASK Mod
Equivalent
M-function
ddemod
QASK Mod Square Constellation
6-161
QASK Mod
Square Con stel l ati on
Catagory Passband Mappi ng/Modul ati on
Location Di gi tal Mo/Dem, Passband Subl i brary
Description The QASK (quadrature ampl i tude shi ft-keyi ng) Mod Square Constel l ati on
bl ock maps an i nput si gnal i nto a square constel l ati on si gnal space and then
modul ates the mapped si gnal . Thi s bl ock i s a combi nati on of the QASK Map
Square Constel l ati on and QM DSB AM bl ocks. Refer to thei r i ndi vi dual
reference pages for descri pti ons of the techni ques i nvol ved.
QASK Mod Squar e Constel l ati on bl ock i s a passband si mul ati on bl ock. Ther e
ar e thr ee ti mi ng var i abl es i n thi s bl ock: durati on of di gi t (T
d
), carr i er frequency
(f
c
), and sampl e ti me (T
s
). You must sel ect val ues for these vari abl es so that
they sati sfy the mathemati cal rel ati ons bel ow:
Td > 1/f c > 2Ts
Thi s bl ock accepts a scal ar i nput i n the r ange [0, M-1], where M i s the mul ti pl e
number. The mul ti pl e number equal s the total number of poi nts i n the square
constel l ati on and typi cal l y i s equal to 2
K
, where K i s a posi ti ve i nteger . The
output of thi s bl ock i s a modul ated anal og si gnal wi th a maxi mum ampl i tude
equal to one.
Dialog Box
Speci fy the i nput range. The i nput di gi t i s i n the
i nteger r ange [0,M-1]. Gener al l y M=2
K
, where K
i s a posi ti ve i nteger .
The sampl e ti me of the i nput di gi t. When thi s
parameter i s a l ength 2 vector, the second
el ement i s the offset val ue.
The car ri er frequency.
The i ni ti al phase of the car r i er fr equency.
The cal cul ati on sampl e ti me. By the
Nyqui st sampl i ng theor em,
1/s ampl e_t i me > 2car r i e r _f r e quency .
QASK Mod Square Constellation
6-162
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block QASK Demod Square Constel l ati on
Equivalent
M-function dmod for modul ati on
QASK Demod Square Constellation
6-163
QASK Demod
Square Con stel l ati on
Catagory Passband Demodul ati on/Demappi ng
Location Di gi tal Mo/Dem, Passband Subl i brary
Description The QASK (quadrature ampl i tude shi ft-keyi ng) Demod Square Constel l ati on
bl ock demodul ates an i nput si gnal and then demaps the demodul ated si gnal .
Thi s bl ock i s a combi nati on of the QM DSB-SC ADM and QASK Demap Square
Constel l ati on bl ocks. Refer to thei r i ndi vi dual reference pages for descri pti ons
of the techni ques i nvol ved.
The QASK Demod Square Constel l ati on i s a passband si mul ati on bl ock. There
ar e thr ee ti mi ng var i abl es i n thi s bl ock: durati on of di gi t (T
d
), carr i er frequency
(f
c
), and sampl e ti me (T
s
). You must sel ect val ues for these vari abl es so that
they sati sfy the mathemati cal rel ati ons bel ow:
Td > 1/f c > 2Ts
Thi s bl ock uses a defaul t 5th or der Butter wor th l owpass fi l ter , whi ch i t
gener ates usi ng the command:
[ num, de n] = but t er ( 5, Fc 2Ts ) ;
Thi s bl ock accepts a modul ated anal og si gnal wi th a maxi mum ampl i tude
equal to one. The output of thi s bl ock i s an i nteger i n the r ange [0, M-1], where
M i s the mul ti pl e number .
Dialog Box
Match these par ameter s to the ones used i n the
cor r espondi ng QASK Mod Squar e Constel l ati on
bl ock. The offset val ue i n Symbol interval can
be di ffer ent.
The cal cul ati on sampl e ti me. By the
Nyqui st sampl i ng theor em,
1/s ampl e_t i me > 2car r i e r _f r e quency .
QASK Demod Square Constellation
6-164
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block QASK Mod Squar e Constel l ati on
Equivalent
M-function ddemod for demodul ati on
QASK Mod Circle Constellation
6-165
QASK Mod
Ci rcl e Constel l ati on
Catagory Passband Mappi ng/Modul ati on
Location Di gi tal Mo/Dem, Passband Subl i brary
Description The QASK (quadr ature ampl i tude shi ft-keyi ng) Mod Ci rcl e Constel l ati on bl ock
maps an i nput si gnal i nto a ci r cl e constel l ati on si gnal space and then
modul ates the mapped si gnal . Thi s bl ock i s a combi nati on of the QASK Map
Ci r cl e Constel l ati on and QM DSB AM bl ocks. Refer to thei r reference pages for
descr i pti ons of the techni ques i nvol ved.
QASK Mod Ci r cl e Constel l ati on i s a passband si mul ati on bl ock. Ther e ar e
three ti mi ng vari abl es i n thi s bl ock: durati on of di gi t (T
d
), carr i er frequency
(f
c
), and sampl e ti me (T
s
). You must sel ect val ues for these vari abl es so that
they sati sfy the mathemati cal rel ati ons bel ow:
Td > 1/f c > 2Ts
Thi s bl ock accepts a scal ar i nput i n the r ange [0, M-1], where M i s the mul ti pl e
number. The mul ti pl e number equal s the total number of poi nts i n the ci r cl e
constel l ati on. The output of thi s bl ock i s a modul ated anal og si gnal wi th a
maxi mum ampl i tude equal to one.
The modul ati on i ni ti al phase defaul ts to zero i n thi s bl ock. I f you want to use a
di ffer ent val ue, use the QASK Map Ci r cl e Constel l ati on and QM DSB AM
bl ocks separ atel y.
QASK Mod Circle Constellation
6-166
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block QASK Demod Ci r cl e Constel l ati on
Equivalent
M-function dmod for modul ati on
The number of symbol s on each ci r cl e. The
el ements of thi s vector must be posi ti ve i nteger s.
The r adi us and phase shi ft for each ci r cl e. The
l ength of each of these vectors must equal the
l ength of the Number of symbols on each
circle vector .
The sampl e ti me of the i nput di gi t. When thi s
par ameter i s a two-el ement vector , the second
el ement i s the offset val ue.
The si gnal s car r i er fr equency.
The cal cul ati on sampl e ti me. By the
Nyqui st sampl i ng theorem,
1/s ampl e _t i me > 2car r i e r _f r eque ncy .
QASK Demod Circle Constellation
6-167
QASK Demod
Ci rcl e Constel l ati on
Catagory Passband Demodul ati on/Demappi ng
Location Di gi tal Mo/Dem, Passband Subl i brary
Description The QASK (quadrature ampl i tude shi ft-keyi ng) Demod Ci rcl e Constel l ati on
bl ock demodul ates an i nput si gnal and then demaps the demodul ated si gnal .
Thi s bl ock i s a combi nati on of the QM DSB-SC ADM and QASK Demap Ci rcl e
Constel l ati on bl ocks. Refer to thei r reference pages for descri pti ons of the
techni ques i nvol ved.
Thi s bl ock uses a defaul t 5th or der Butter wor th fi l ter, whi ch i t gener ates by
usi ng the command:
[ num, de n] = but t er ( 5, Fc *2*Ts ) ;
The i nput to thi s bl ock i s an anal og modul ated si gnal wi th a maxi mum
ampl i tude equal to one. I t outputs i ntegers i n the r ange [0, M-1], wher e M i s
the mul ti pl e number .
Dialog Box
Match these par ameter s to the ones used i n the
cor r espondi ng MASK Mod bl ock.The offset i n
Symbol interval may be di ffer ent.
The cal cul ati on sampl e ti me. By the
Nyqui st sampl i ng theor em,
1/s ampl e_t i me > 2car r i e r _f r e quency .
QASK Demod Circle Constellation
6-168
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/Yes
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block QASK Mod Ci r cl e Constel l ati on
Equivalent
M-function ddemod for demodul ati on computati on
QASK Mod Arbitrary Constellation
6-169
QASK Mod
Ar bi trary Constel l ati on
Catagory Passband Mappi ng/Modul ati on
Location Di gi tal Mo/Dem, Passband Subl i brary
Description The QASK (quadrature ampl i tude shi ft-keyi ng) Mod Arbi trar y Constel l ati on
bl ock maps an i nput si gnal i nto a user -defi ned constel l ati on si gnal space and
then modul ates the mapped si gnal . Thi s bl ock i s a combi nati on of the QASK
Map Arbi trar y Constel l ati on and QM DSB AM bl ocks. Refer to thei r r efer ence
pages for descr i pti ons of the techni ques i nvol ved.
QASK Mod Ar bi tr ary Constel l ati on i s a passband si mul ati on bl ock. There are
three ti mi ng vari abl es i n thi s bl ock: durati on of di gi t (T
d
), carr i er frequency
(f
c
), and sampl e ti me (T
s
). You must sel ect val ues for these vari abl es so that
they sati sfy the mathemati cal rel ati ons bel ow:
Td > 1/f c > 2*Ts
Thi s bl ock accepts a scal ar i nput i n the r ange [0, M-1], where M i s the mul ti pl e
number. The mul ti pl e number equal s the total number of poi nts i n the
user -defi ned ar bi tr ar y constel l ati on. The output of thi s bl ock i s a modul ated
anal og si gnal wi th a maxi mum ampl i tude equal to one.
Dialog Box
Defi ne the i n-phase and quadr ature components
of each poi nt i n the constel l ati on.
The sampl e ti me of the i nput di gi t. When thi s
parameter i s a two-el ement vector , the second
el ement i s the offset val ue
The car ri er frequency.
The i ni ti al phase of the car r i er fr equency.
The cal cul ati on sampl e ti me. By the
Nyqui st sampl i ng theor em,
1/s ampl e_t i me > 2car r i e r _f r e quency .
QASK Mod Arbitrary Constellation
6-170
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block QASK Demod Ar bi trary Constel l ati on
Equivalent
M-function dmod for modul ati on
QASK Demod Arbitrary Constellation
6-171
QASK Demod
Ar bi trary Constel l ati on
Catagory Passband Demodul ati on/Demappi ng
Location Di gi tal Mo/Dem, Passband Subl i brary
Description The QASK (quadrature ampl i tude shi ft-keyi ng) Demod Arbi trar y
Constel l ati on bl ock demodul ates an i nput si gnal and then demaps the
demodul ated si gnal . Thi s bl ock i s a combi nati on of the QM DSB-SC ADM and
QASK Demap Ar bi tr ary Constel l ati on bl ocks. Refer to thei r reference pages for
descr i pti ons of the techni ques i nvol ved.
Thi s bl ock uses a defaul t 5th or der Butter wor th fi l ter, whi ch i t gener ates by
usi ng the command:
[ num, de n] = but t er ( 5, Fc *2*Ts ) ;
The i nput to thi s bl ock i s an anal og modul ated si gnal wi th a maxi mum
ampl i tude equal to one. I t outputs i ntegers i n the r ange [0, M-1], wher e M i s
the mul ti pl e number . The mul ti pl e number equal s the total number of poi nts
i n the constel l ati on; i t i s al so equal to the l ength of the evocator of i n-phase
components.
Dialog Box
Match these par ameter s to the ones used i n the
cor r espondi ng QASK Mod bl ock. The offset val ue
i n Symbol interval can be di fferent.
The cal cul ati on sampl e ti me. By the
Nyqui st sampl i ng theor em,
1/s ampl e_t i me > 2car r i e r _f r e quency .
QASK Demod Arbitrary Constellation
6-172
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/Yes
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block QASK Mod Ar bi tr ary Constel l ati on
Equivalent
M-function ddemod for demodul ati on computati on
MFSK Mod
6-173
MFSK Mod
Catagory Passband Mappi ng/Modul ati on
Location Di gi tal Mo/Dem, Passband Subl i brary
Description The MFSK (mul ti pl e frequency shi ft-keyi ng) Mod bl ock maps an i nput si gnal
and then modul ates the mapped si gnal . Thi s bl ock i s a combi nati on of the
MFSK Map and FM bl ocks. Refer to the i ndi vi dual r efer ence pages for these
bl ocks for descr i pti ons of the techni ques i nvol ved.
MFSK Mod i s a passband si mul ati on bl ock. There ar e three ti mi ng vari abl es i n
thi s bl ock: dur ati on of di gi t (T
d
), car ri er frequency (f
c
), and sampl e ti me (T
s
).
You must sel ect val ues for these var i abl es so that they sati sfy the
mathemati cal r el ati ons bel ow:
Td > 1/f c > 2Ts
Thi s bl ock accepts a scal ar i nput i n the r ange [0, M-1], where M i s the mul ti pl e
number. The output of thi s bl ock i s a modul ated anal og si gnal wi th a maxi mum
ampl i tude equal to one.
Dialog Box
The frequency separati on between two
nei ghbor i ng i nput i nteger s. The tone space
i s al so known as the frequency separation.
The sampl e ti me of the i nput di gi t. When thi s
parameter i s a two-el ement vector , the second
el ement i s the offset val ue
The car ri er frequency.
The i ni ti al phase of the car r i er fr equency.
The cal cul ati on sampl e ti me. By the
Nyqui st sampl i ng theor em,
1/s ampl e_t i me > 2car r i e r _f r e quency .
MFSK Mod
6-174
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block MFSK Demodul ati on
Equivalent
M-function
dmod
Coherent MFSK Demod
6-175
Coherent MFSK
Demod
Catagory Passband Demodul ati on/Demappi ng
Location Di gi tal Mo/Dem, Passband Subl i brary
Description The Coherent MFSK (mul ti pl e frequency shi ft-keyi ng) Demod bl ock
demodul ates an i nput si gnal and then demaps the demodul ated si gnal . Thi s
bl ock i s a combi nati on of the Coher ent MFSK Cor r Demap and Mi n/Max
Demap bl ocks. Refer to thei r i ndi vi dual reference pages for descr i pti ons of the
techni ques i nvol ved.
Coher ent MFSK Demod i s a passband si mul ati on bl ock. Ther e ar e three ti mi ng
var i abl es i n thi s bl ock: dur ati on of di gi t (T
d
), carr i er fr equency (f
c
), and sampl e
ti me (T
s
). You must sel ect val ues for these var i abl es so that they sati sfy the
mathemati cal r el ati ons bel ow:
Td > 1/f c > 2Ts
Dialog Box
Match these par ameter s to the ones used i n the
cor r espondi ng MFSK Mod bl ock. The offset val ue
i n Symbol interval can be di fferent.
The cal cul ati on sampl e ti me. By the
Nyqui st sampl i ng theor em,
1/s ampl e_t i me > 2car r i e r _f r e quency .
Coherent MFSK Demod
6-176
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/Yes
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block MFSK Mod
Equivalent
M-function
de mod
Noncoherent MFSK Demod
6-177
Noncoherent MFSK
Demod
Catagory Passband Demodul ati on/Demappi ng
Location Di gi tal Mo/Dem, Passband Subl i brary
Description The Noncoher ent MFSK (mul ti pl e fr equency shi ft-keyi ng) Demod bl ock
demodul ates an i nput si gnal and then demaps the demodul ated si gnal . Thi s
bl ock i s a combi nati on of the Noncoherent MFSK Corr Demap and Mi n/Max
Demap Arbi trar y Constel l ati on bl ocks. Refer to thei r i ndi vi dual reference
pages for descr i pti ons of the techni ques i nvol ved.
Noncoherent MFSK Demod i s a passband si mul ati on bl ock. Ther e ar e three
ti mi ng vari abl es i n thi s bl ock: durati on of di gi t (T
d
), car ri er frequency (f
c
), and
sampl e ti me (T
s
). You must sel ect val ues for these var i abl es so that they sati sfy
the mathemati cal r el ati ons bel ow:
Td > 1/f c > 2Ts
Dialog Box
Match these par ameter s to the ones used i n the
cor r espondi ng MFSK Mod bl ock. The offset val ue
i n Symbol interval can be di fferent.
The cal cul ati on sampl e ti me. By the
Nyqui st sampl i ng theor em,
1/s ampl e_t i me > 2car r i e r _f r e quency .
Noncoherent MFSK Demod
6-178
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/Yes
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block MFSK Mod
Equivalent
M-function
ddemod
MPSK Mod
6-179
MPSK Mod
Catagory Passband Mappi ng/Modul ati on
Location Di gi tal Mo/Dem, Passband Subl i brary
Description The MPSK (mul ti pl e phase shi ft-keyi ng) Mod bl ock maps an i nput si gnal and
then modul ates the mapped si gnal . Thi s bl ock i s a combi nati on of the MPSK
Map and PM bl ocks. Refer to thei r i ndi vi dual r efer ence pages for descr i pti ons
of the techni ques i nvol ved.
MPSK Mod i s a passband si mul ati on bl ock. There ar e three ti mi ng vari abl es i n
thi s bl ock: dur ati on of di gi t (T
d
), car ri er frequency (f
c
), and sampl e ti me (T
s
).
You must sel ect val ues for these var i abl es so that they sati sfy the
mathemati cal r el ati ons bel ow:
Td > 1/f c > 2Ts
The i nput si gnal to thi s bl ock i s an i nteger i n the r ange [0, M-1], wher e M i s the
mul ti pl e number . The output i s a modul ated anal og si gnal wi th a maxi mum
ampl i tude equal to one.
Dialog Box
Speci fy the range of the i nput di gi ts. The r ange i s
[0, M-1].
The sampl e ti me of the tr ansmi tted di gi t symbol .
When thi s par ameter i s a two-el ement vector , the
second el ement i s the offset val ue.
The frequency of the car r i er si gnal .
The i ni ti al phase of the car r i er fr equency.
The cal cul ati on sampl e ti me. By the
Nyqui st sampl i ng theor em,
1/s ampl e_t i me > 2car r i e r _f r e quency .
MPSK Mod
6-180
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block MPSK Demod
Equivalent
M-function
dmod
MPSK Demod
6-181
MPSK Demod
Catagory Passband Demodul ati on/Demappi ng
Location Di gi tal Mo/Dem, Passband Subl i brary
Description The MPSK (mul ti pl e phase shi ft-keyi ng) Demod bl ock demodul ates an i nput
si gnal and then demaps the demodul ated si gnal . Thi s bl ock i s a combi nati on of
the MPSK Cor r Demap and Mi n/Max Demap bl ocks. Refer to thei r i ndi vi dual
reference pages for descri pti ons of the techni ques i nvol ved.
MPSK Demod i s a passband si mul ati on bl ock. There are thr ee ti mi ng var i abl es
i n thi s bl ock: durati on of di gi t (T
d
), car ri er frequency (f
c
), and sampl e ti me (T
s
).
You must sel ect val ues for these var i abl es so that they sati sfy the
mathemati cal r el ati ons bel ow:
Td > 1/f c > 2Ts
The i nput si gnal to thi s bl ock i s a modul ated anal og si gnal wi th a maxi mum
ampl i tude equal to one. The output i s an i nteger i n the range
[0, M-1], wher e M i s the mul ti pl e number .
Dialog Box
Match these par ameter s to the ones used i n the
cor r espondi ng MPSK Mod bl ock. The offset val ue
i n Symbol interval may be di ffer ent.
The cal cul ati on sampl e ti me. By the
Nyqui st sampl i ng theor em,
1/s ampl e_t i me > 2car r i e r _f r e quency .
MPSK Demod
6-182
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block MPSK Mod
Equivalent
M-function
ddemod
6-183
6
Digital Modulation/ Demodulation
Methods for Baseband Simulation
The bl ocks i ncl uded i n the Di gi tal Modul ati on/Demodul ati on, Baseband
Subl i br ary ar e the baseband counter parts of the bl ocks i ntr oduced i n the
Di gi tal Modul ati on/Demodul ati on, Passband Si mul ati on Subl i brar y.
You must speci fy the numerator s and denomi nators of the l owpass fi l ters
tr ansfer functi on when usi ng the MASK and QASK demodul ati on bl ocks. Read
the i ntr oducti on of the l ast secti on for possi bl e choi ces. You can si mpl y set both
the numerator and denomi nator to 1 for your si mul ati on i f you choose not to
use a fi l ter.
6-184
The fi gur e bel ow shows the Di gi tal Modul ati on/Demodul ati on Baseband
Subl i br ary:
Figure 6-1: The Digital Modulation/ Demodulation Baseband Sublibrary
6-185
Digital Modulation/ Demodulation
Baseband Reference Table
Thi s tabl e l i sts the bl ocks i n the Di gi tal Mod/Demod Mappi ng/Demappi ng
Baseband subl i br ary. (Thi s tabl e l i sts the bl ocks i n al phabeti cal or der for your
conveni ence.):
Block Name Description
Coher ent MFSK Demod CE Mul ti pl e fr equency shi ft-keyi ng (MFSK)
baseband coher ent demodul ati on fol l owed
by mi n/max demappi ng
MASK Demod CE Doubl e si deband ampl i tude demodul ati on
(DSB ADM) fol l owed by mul ti pl e ampl i tude
shi ft-keyi ng (MASK) baseband
demodul ati on
MASK Mod CE Mul ti pl e ampl i tude shi ft-keyi ng (MASK)
baseband mappi ng fol l owed by doubl e
si deband ampl i tude modul ati on (DSB AM)
MFSK Mod CE Mul ti pl e fr equency shi ft-keyi ng (MFSK)
baseband mappi ng fol l owed by fr equency
modul ati on (FM)
MPSK Demod CE Mul ti pl e phase shi ft-keyi ng (MPSK)
baseband demodul ati on fol l owed by mi n/
max demappi ng
MPSK Mod CE Mul ti pl e phase shi ft-keyi ng baseband
mappi ng fol l owed by phase modul ati on
(PM)
Noncoherent MFSK Demod
CE
Mul ti pl e fr equency shi ft-keyi ng baseband
noncoher ent demodul ati on fol l owed by mi n/
max demappi ng
6-186
QASK CE Demod Arbi trary
Constel l ati on
Doubl e si deband suppr essed car ri er
ampl i tude demodul ati on (DSB-SC ADM)
fol l owed by quadr atur e ampl i tude
shi ft-keyi ng (QASK) demodul ati on usi ng an
ar bi tr ary constel l ati on
QASK Demod CE Ci r cl e
Constel l ati on
Doubl e si deband suppr essed car ri er
ampl i tude demodul ati on (DSB-SC ADM)
fol l owed by quadr atur e ampl i tude
shi ft-keyi ng (QASK) demodul ati on usi ng a
ci rcl e constel l ati on
QASK Demod CE Square
Constel l ati on
Doubl e si deband suppr essed car ri er
ampl i tude demodul ati on (DSB-SC ADM)
fol l owed by quadr atur e ampl i tude
shi ft-keyi ng (QASK) demodul ati on usi ng a
squar e constel l ati on
QASK Mod CE Ar bi trary
Constel l ati on
Quadratur e ampl i tude shi ft-keyi ng (QASK)
modul ati on usi ng an arbi trar y constel l ati on
fol l owed by doubl e si deband suppr essed
carr i er ampl i tude modul ati on (DSB AM)
QASK Mod CE Ci r cl e
Constel l ati on
Quadratur e ampl i tude shi ft-keyi ng (QASK)
modul ati on usi ng a ci r cl e constel l ati on
fol l owed by doubl e si deband suppr essed
carr i er ampl i tude modul ati on (DSB AM)
QASK Mod Squar e
Constel l ati on
Quadratur e ampl i tude shi ft-keyi ng (QASK)
modul ati on usi ng a square constel l ati on
fol l owed by doubl e si deband suppr essed
carr i er ampl i tude modul ati on (DSB AM)
Block Name Description
MASK Mod CE
6-187
6
MASK Mod CE
Catagory Baseband Mappi ng/Modul ati on
Location Di gi tal Mo/Dem, Baseband Subl i brar y
Description The MASK (mul ti pl e ampl i tude shi ft-keyi ng) Mod CE bl ock maps an i nput
si gnal and then modul ates the mapped si gnal wi th a compl ex envel ope. Thi s
bl ock i s a combi nati on of the MASK Map and DSB-SC AM CE bl ocks. Refer to
the r efer ence pages for these bl ocks for a di scussi on of the techni ques i nvol ved.
Thi s bl ock accepts a scal ar i nput i n the r ange [0, M-1], where M i s the mul ti pl e
number. Typi cal l y, M equal s 2
K
, wher e K i s a posi ti ve i nteger. The output of
thi s bl ock i s a modul ated anal og si gnal wi th a maxi mum ampl i tude equal to
one.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/Compl ex
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block MASK Demod CE
Equivalent
M-function dmodc e
Speci fy the i nput di gi t r ange, [0, M-1].
The sampl e ti me of the i nput symbol . When thi s
parameter i s a two-el ement vector , the second
el ement i s the offset val ue.
The i ni ti al phase of the car r i er si gnal .
MASK Demod CE
6-188
MASK Demod CE
Catagory Baseband Demodul ati on/Demappi ng
Location Di gi tal Mo/Dem, Baseband Subl i brar y
Description The MASK (mul ti pl e ampl i tude shi ft-keyi ng) Demod CE bl ock demodul ates
wi th compl ex envel ope an i nput si gnal and then the demaps the demodul ated
si gnal . Thi s bl ock i s a combi nati on of the Costas PLL DSB ADM CE and the
MASK Demap bl ocks. Refer to the i ndi vi dual r efer ence pages for these bl ocks
for di scussi ons of the techni ques i nvol ved.
Thi s bl ock accepts a modul ated compl ex si gnal wi th i ts maxi mum ampl i tude
equal to one. I t outputs i ntegers i n the range [0, M-1], where M i s the mul ti pl e
number.
Dialog Box
Match these par ameter s to the ones used i n the
cor r espondi ng MASK Mod Ce bl ock. The offset
val ue i n Symbol interval can be di fferent.
The i ni ti al phase of the car r i er si gnal .
Speci fy the numer ator of the l owpass fi l ter used
i n the demodul ati on. Set thi s parameter to 1 i f
you do not need a l owpass fi l ter.
The denomi nator of the l owpass fi l ter . I f the
fi l ter i s FI R or i f you do not need a l owpass fi l ter ,
set thi s par ameter to 1.
The fi l ter sampl e ti me. The sampl e ti me of the
fi l ter i s al so the bl ock cal cul ati on sampl e ti me.
MASK Demod CE
6-189
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs Compl ex/No
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block MASK Mod CE
Equivalent
M-function dde modc e
QASK Mod CE Square Constellation
6-190
QASK Mod CE
Square Constel l ati on
Catagory Baseband Mappi ng/Modul ati on
Location Di gi tal Mo/Dem, Baseband Subl i brar y
Description The QASK (quadratur e ampl i tude shi ft-keyi ng) Mod Square CE Constel l ati on
bl ock maps an i nput si gnal i nto a squar e constel l ati on si gnal space and then
modul ates the mapped si gnal wi th compl ex envel ope. Thi s bl ock i s a
combi nati on of the QASK Map Squar e Constel l ati on and QM DSB AM CE
bl ocks. Refer to thei r i ndi vi dual reference pages for descri pti ons of the
techni ques i nvol ved.
QASK Mod CE Squar e Constel l ati on i s a passband si mul ati on bl ock. There ar e
thr ee ti mi ng var i abl es i n thi s bl ock: durati on of di gi t (T
d
), carri er fr equency
(f
c
), and sampl e ti me (T
s
). You must sel ect val ues for these var i abl es so that
they sati sfy the mathemati cal rel ati ons bel ow:
Td > 1/f c > 2Ts
Thi s bl ock accepts a scal ar i nput i n the r ange [0, M-1], wher e M i s the mul ti pl e
number. The mul ti pl e number equal s the total number of poi nts i n the square
constel l ati on and typi cal l y i s equal to 2
K
, where K i s a posi ti ve i nteger . The
output of thi s bl ock i s a modul ated anal og compl ex si gnal wi th a maxi mum
ampl i tude of both the i n-phase and quadratur e components equal to one.
Dialog Box
Speci fy the i nput r ange. The i nput di gi t i s i n the
i nteger r ange [0,M-1].
The sampl e ti me of the i nput symbol . When thi s
par ameter i s a two-el ement vector , the second
el ement i s the offset val ue.
The i ni ti al phase of the car r i er fr equency.
The cal cul ati on sampl e ti me. By the
Nyqui st sampl i ng theorem,
1/s ampl e _t i me > 2*c ar r i er _f r eque nc y.
QASK Mod CE Square Constellation
6-191
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/Compl ex
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block QASK Demod CE Square Constel l ati on
Equivalent
M-function dmodce
QASK Demod CE Square Constellation
6-192
QASK Demod CE
Square Constel l ati on
Catagory Baseband Mappi ng/Modul ati on
Location Di gi tal Mo/Dem, Baseband Subl i brar y
Description The QASK (quadrature ampl i tude shi ft-keyi ng) Demod CE Squar e
Constel l ati on bl ock demodul ates a compl ex i nput si gnal and then demaps the
demodul ated si gnal usi ng QASK. Thi s bl ock i s a combi nati on of the QM
DSB-SC ADM CE and QASK Demap Square Constel l ati on bl ocks. Refer to
thei r i ndi vi dual reference pages for descri pti ons of the techni ques i nvol ved.
QASK Demod Squar e Constel l ati on i s a passband si mul ati on bl ock. There are
thr ee ti mi ng var i abl es i n thi s bl ock: durati on of di gi t (T
d
), carri er fr equency
(f
c
), and sampl e ti me (T
s
). You must sel ect val ues for these var i abl es so that
they sati sfy the mathemati cal rel ati ons bel ow:
Td > 1/f c > 2Ts
Thi s bl ock accepts a modul ated compl ex anal og si gnal wi th a maxi mum
ampl i tude equal to one i n both the i n-phase and quadratur e components. The
output of thi s bl ock i s an i nteger i n the r ange [0, M-1], wher e M i s the mul ti pl e
number.
Dialog Box
Match these par ameter s to the ones used i n the
cor r espondi ng QASK Mod CE Square Constel l a-
ti on bl ock. The offset val ue i n Symbol interval
can be di fferent.
Speci fy the numer ator of the l owpass fi l ter used
i n the demodul ati on. Set thi s parameter to 1 i f
you do not need a l owpass fi l ter.
The denomi nator of the l owpass fi l ter. I f the fi l ter
i s FI R or i f you do not need a l owpass fi l ter , set
thi s par ameter to 1.
The i ni ti al phase of the car r i er si gnal .
The fi l ter sampl e ti me, whi ch al so speci fi es the
cal cul ati on sampl e ti me.
QASK Demod CE Square Constellation
6-193
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs Compl ex/No
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block QASK Mod CE Square Constel l ati on
Equivalent
M-function dde modc e
QASK Mod CE Circle Constellation
6-194
QASK Mod CE
Ci rcl e Constel l ati on
Catagory Baseband Mappi ng/Modul ati on
Location Di gi tal Mo/Dem, Baseband Subl i brar y
Description The QASK (quadrature ampl i tude shi ft-keyi ng) Mod CE Ci rcl e
Constel l ati on bl ock maps a compl ex i nput si gnal i nto a ci rcl e constel l ati on
si gnal space and then modul ates the mapped si gnal . Thi s bl ock i s a
combi nati on of the QASK Map Ci r cl e Constel l ati on and QM DSB AM CE
bl ocks. Refer to thei r r efer ence pages for descr i pti ons of the techni ques
i nvol ved.
QASK Mod CE Ci r cl e Constel l ati on i s a passband si mul ati on bl ock. Ther e ar e
thr ee ti mi ng var i abl es i n thi s bl ock: durati on of di gi t (T
d
), carri er fr equency
(f
c
), and sampl e ti me (T
s
). You must sel ect val ues for these var i abl es so that
they sati sfy the mathemati cal rel ati ons bel ow:
Td > 1/f c > 2Ts
Thi s bl ock accepts a scal ar i nput i n the r ange [0, M-1], wher e M i s the mul ti pl e
number. The mul ti pl e number equal s the total number of poi nts i n the ci r cl e
constel l ati on. The output of thi s bl ock i s a modul ated anal og si gnal wi th a
maxi mum ampl i tude equal to one.
QASK Mod CE Circle Constellation
6-195
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/Compl ex
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block QASK Demod CE Ci r cl e Constel l ati on
Equivalent
M-function dmodc e
The number of symbol s on each ci r cl e. The
el ements of thi s vector must be posi ti ve i nteger s.
The r adi us and phase shi ft for each ci r cl e. The
l ength of thi s vector must equal the l ength of the
Number of symbols in each circle vector .
The i ni ti al phase of the car r i er si gnal .
The sampl e ti me of the i nput di gi t. When thi s
parameter i s a two-el ement vector , the second
el ement i s the offset val ue.
The cal cul ati on sampl i ng ti me. By the
Nyqui st sampl i ng theor em,
1/s ampl e_t i me > 2*c ar r i e r _f r eque nc y.
QASK Demod CE Circle Constellation
6-196
QASK Demod CE
Ci rcl e Constel l ati on
Catagory Baseband Demodul ati on/Demappi ng
Location Di gi tal Mo/Dem, Baseband Subl i brar y
Description The QASK (quadrature ampl i tude shi ft-keyi ng) Demod CE Ci r cl e
Constel l ati on bl ock demodul ates a compl ex i nput si gnal and then demaps the
demodul ated si gnal . Thi s bl ock i s a combi nati on of the QM DSB-SC ADM CE
and QASK Demap Ci rcl e Constel l ati on bl ocks. Refer to thei r i ndi vi dual
reference pages for descri pti ons of the techni ques i nvol ved.
The i nput to thi s bl ock i s an anal og modul ated si gnal wi th a maxi mum
ampl i tude equal to one. I t outputs i nteger s i n the r ange [0, M-1], wher e M i s
the mul ti pl e number.
Dialog Box
Match these par ameter s to the ones used i n the
cor r espondi ng MASK Mod CE Ci r cl e Constel l a-
ti on bl ock. The offset val ue i n Symbol interval
can be di fferent.
Speci fy the numer ator of the l owpass fi l ter used
i n the demodul ati on. Set thi s parameter to 1 i f
you do not need a l owpass fi l ter.
The denomi nator of the l owpass fi l ter. I f the fi l ter
i s FI R or i f you do not need a l owpass fi l ter , set
thi s par ameter to 1.
The cal cul ati on sampl e ti me. By the
Nyqui st sampl i ng theorem,
1/s ampl e _t i me > 2*c ar r i er _f r eque nc y.
QASK Demod CE Circle Constellation
6-197
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs Compl ex/No
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block QASK Mod CE Ci r cl e Constel l ati on
Equivalent
M-function dde modc e
QASK Mod CE Arbitrary Constellation
6-198
QASK Mod CE
Ar bi trar y Constel l ati on
Catagory Baseband Mappi ng/Modul ati on
Location Di gi tal Mo/Dem, Baseband Subl i brar y
Description The QASK (quadrature ampl i tude shi ft-keyi ng) Mod CE Ar bi tr ar y
Constel l ati on bl ock maps a compl ex i nput si gnal i nto a user-defi ned
constel l ati on si gnal space and then modul ates the mapped si gnal . Thi s bl ock i s
a combi nati on of the QASK Map Ar bi tr ary Constel l ati on and QM DSB AM CE
bl ocks. Refer to thei r i ndi vi dual reference pages for descri pti ons of the
techni ques i nvol ved.
Thi s bl ock accepts a scal ar i nput i n the r ange [0, M-1], wher e M i s the mul ti pl e
number. The mul ti pl e number equal s the total number of poi nts i n the
user -defi ned ar bi tr ary constel l ati on. The output of thi s bl ock i s a modul ated
anal og si gnal wi th a maxi mum ampl i tude equal to one.
Dialog Box
Defi ne the i n-phase and quadr atur e components
of each poi nt i n the constel l ati on.
The sampl e ti me of the i nput symbol . When thi s
par ameter i s a two-el ement vector , the second
el ement i s the offset val ue.
The i ni ti al phase of the car r i er fr equency.
The cal cul ati on sampl e ti me. By the
Nyqui st sampl i ng theorem,
1/s ampl e _t i me > 2*c ar r i er _f r eque nc y.
QASK Mod CE Arbitrary Constellation
6-199
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/Compl ex
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block QASK Demod CE Arbi trary Constel l ati on
Equivalent
M-function dmodc e
QASK Demod CE Arbitrary Constellation
6-200
QASK Demod CE
Ar bi trar y Constel l ati on
Catagory Baseband Demodul ati on/Demappi ng
Location Di gi tal Mo/Dem, Baseband Subl i brar y
Description The QASK (quadrature ampl i tude shi ft-keyi ng) Demod CE Ar bi tr ary
Constel l ati on bl ock demodul ates a compl ex i nput si gnal and then demaps the
demodul ated si gnal . Thi s bl ock i s a combi nati on of the QM DSB-SC ADM CE
and QASK Demap Ar bi tr ar y Constel l ati on bl ocks. Refer to thei r r efer ence
pages for descr i pti ons of the techni ques i nvol ved.
The i nput to thi s bl ock i s an anal og modul ated si gnal wi th a maxi mum
ampl i tude equal to the el ement of maxi mum absol ute val ue i n the vector of
i n-phase component. I t outputs i ntegers i n the r ange [0, M-1], wher e M i s the
mul ti pl e number. The mul ti pl e number equal s the total number of poi nts i n the
constel l ati on; i t i s al so equal to the l ength of the vector of i n-phase components.
Dialog Box
Match these par ameter s to the ones used i n the
cor r espondi ng QASK Mod CE Ar bi tr ar y Constel -
l ati on bl ock. The offset val ue i n Symbol
interval can be di ffer ent.
Speci fy the numer ator and denomi nator of the
l owpass fi l ter used i n the demodul ati on. Set thi s
par ameter to 1 i f you do not need a l owpass
fi l ter .I f the fi l ter i s FI R set the denomi nator to 1.
The i ni ti al phase of the car r i er si gnal .
The cal cul ati on sampl e ti me. By the
Nyqui st sampl i ng theorem,
1/s ampl e _t i me > 2*c ar r i er _f r eque nc y.
QASK Demod CE Arbitrary Constellation
6-201
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs Yes/No
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block QASK Mod CE Arbi trary Constel l ati on
Equivalent
M-function dde modc e
MFSK Mod CE
6-202
MFSK Mod CE
Catagory Baseband Mappi ng/Modul ati on
Location Di gi tal Mo/Dem, Baseband Subl i brar y
Description The MFSK (mul ti pl e frequency shi ft-keyi ng) Mod CE bl ock maps a compl ex
i nput si gnal and then modul ates the mapped si gnal . Thi s bl ock i s a
combi nati on of the MFSK Map and FM CE bl ocks. Refer to the i ndi vi dual
reference pages for these bl ocks for descri pti ons of the techni ques i nvol ved.
Thi s bl ock accepts a scal ar i nput i n the r ange [0, M-1], wher e M i s the mul ti pl e
number. The output of thi s bl ock i s a modul ated compl ex anal og si gnal wi th a
maxi mum ampl i tude equal to one.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/Compl ex
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block Coherent MFSK Demod CE
Noncoherent MFSK Demod CE
Equivalent
M-function dmodce
The fr equency separ ati on between two nei gh-
bor i ng i nput i nteger s. The tone space i s al so
known as the fr equency separati on.
The sampl e ti me of the i nput di gi t. When thi s
par ameter i s a two-el ement vector , the second
el ement i s the offset val ue
The i ni ti al phase of the car r i er si gnal .
The cal cul ati on sampl e ti me.
Coherent MFSK Demod CE
6-203
Coherent MFSK
Demod CE
Catagory Baseband Demodul ati on/Demappi ng
Location Di gi tal Mo/Dem, Baseband Subl i brar y
Description The Coherent MFSK (mul ti pl e frequency shi ft-keyi ng) Demod CE bl ock
demodul ates a compl ex i nput si gnal and then demaps the demodul ated si gnal .
Thi s bl ock i s a combi nati on of the Coher ent MFSK Cor r Demap CE and Mi n/
Max Demap bl ocks. Refer to thei r i ndi vi dual r efer ence pages for descr i pti ons of
the techni ques i nvol ved.
The i nput to thi s bl ock i s a modul ated compl ex anal og si gnal . The output i s an
i nteger i n the range [0, M-1], where M i s the mul ti pl e number.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs Compl ex/No
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block MFSK Mod CE
Equivalent
M-function dde modc e
Match these par ameter s to the ones used i n the
cor r espondi ng MFSK Mod CE bl ock. The offset
val ue i n Symbol interval may be di ffer ent.
The i ni ti al phase of the car r i er si gnal .
The cal cul ati on sampl e ti me.
Noncoherent MFSK Demod CE
6-204
Noncoheren t MFSK
Demod CE
Catagory Baseband Demodul ati on/Demappi ng
Location Di gi tal Mo/Dem, Baseband Subl i brar y
Description The Noncoher ent MFSK (mul ti pl e fr equency shi ft-keyi ng) Demod CE bl ock
demodul ates a compl ex i nput si gnal and then demaps the demodul ated si gnal .
Thi s bl ock i s a combi nati on of the Noncoherent MFSK Corr Demap CE and
Mi n/Max Demap Arbi trar y Constel l ati on bl ocks. Refer to thei r i ndi vi dual
reference pages for descri pti ons of the techni ques i nvol ved.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs Compl ex/No
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block MFSK Mod CE
Equivalent
M-function ddemodc e
Match these par ameter s to the ones used i n the
cor r espondi ng MFSK Mod CE bl ock. I n Symbol
interval, the offset val ue may be di ffer ent.
The i ni ti al phase of the car r i er si gnal .
The cal cul ati on sampl e ti me.
MPSK Mod CE
6-205
MPSK Mod CE
Catagory Baseband Mappi ng/Modul ati on
Location Di gi tal Mo/Dem, Baseband Subl i brar y
Description The MPSK (mul ti pl e phase shi ft-keyi ng) Mod CE bl ock maps an i nput si gnal
and then modul ates the mapped si gnal wi th a compl ex envel ope. Thi s bl ock i s
a combi nati on of the MPSK Map and PM CE bl ocks. Refer to thei r i ndi vi dual
reference pages for descri pti ons of the techni ques i nvol ved.
The i nput si gnal to thi s bl ock i s an i nteger i n the range [0, M1], wher e M i s
the mul ti pl e number . The output i s a modul ated compl ex anal og si gnal wi th a
maxi mum ampl i tude equal to one.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block MPSK Demod CE
Equivalent
M-function dmodc e
Speci fy the r ange of the i nput di gi ts. The range i s
[0, M-1].
The sampl e ti me of the tr ansmi tted symbol .
When thi s par ameter i s a two-el ement vector , the
second el ement i s the offset val ue.
The i ni ti al phase of the car r i er fr equency.
MPSK Demod CE
6-206
MPSK Demod CE
Catagory Baseband Demodul ati on/Demappi ng
Location Di gi tal Mo/Dem, Baseband Subl i brar y
Description The MPSK (mul ti pl e phase shi ft-keyi ng) Demod CE bl ock demodul ates a
compl ex i nput si gnal and then demaps the demodul ated si gnal . Thi s bl ock i s a
combi nati on of the MPSK Cor r Demod CE and Mi n/Max Demap bl ocks. Refer
to thei r i ndi vi dual r efer ence pages for descr i pti ons of the techni ques i nvol ved.
The i nput si gnal to thi s bl ock i s a modul ated compl ex anal og si gnal wi th a
maxi mum ampl i tude equal to one. The output i s an i nteger i n the r ange
[0, M-1], where M i s the mul ti pl e number.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block MPSK Mod CE
Equivalent
M-function ddemodc e
Match these par ameters to the ones used i n the
cor r espondi ng MPSK Mod CE bl ock. The offset
val ue i n Symbol interval can be di ffer ent.
The i ni ti al phase of the car r i er si gnal .
The cal cul ati on sampl e ti me.
6-207
6
Mapping/ Demapping for Digital Modulation/
Demodulation
Di gi tal si gnal mappi ng codes an i nput di gi tal si gnal i nto a si gnal ready for
modul ati on. Di gi tal si gnal demappi ng decodes a demodul ated si gnal back i nto
a di gi tal si gnal . A di gi tal modul ati on bl ock can be di vi ded i nto two major par ts:
di gi tal -to-anal og mappi ng and anal og modul ati on. A di gi tal demodul ati on
bl ock can al so be di vi ded i nto two major par ts: anal og demodul ati on and
anal og-to-di gi tal demappi ng.
The mappi ng and demappi ng bl ocks are i n two subl i brari es: the
Di gi tal Mo/Dem Map/Demap Subl i brar y and Di gi tal Mo/Dem-CE Map/Demap
Subl i br ary. Thi s secti on di scusses both baseband and passband si mul ati on
subl i br ari es because these two subl i br ari es shar e qui te a few bl ocks.
Note: The mappi ng bl ocks used i n both baseband and passband have no
functi onal i ty di fferences, so each of these mappi ng bl ocks i s documented onl y
for passband si mul ati on. There ar e no di ffer ences i n how you use these bl ocks
i n baseband.
The fi gur e bel ow shows the Passband Di gi tal Mod/Dem Map/Demap
Subl i br ary:
6-208
Figure 6-17: The Passband Digital Modulation/ Demodulation
Mapping/ Demapping Sublibrary
6-209
The fi gur e bel ow shows the Baseband Di gi tal Mod/Demod Mappi ng/
Demappi ng Subl i brar y:
Figure 6-18: The Baseband Digital Modulation/ Demodulation
Mapping/ Demapping Sublibrary
6-210
Thi s tool box uses the term symbol interval i n di gi tal mappi ng/demappi ng as
wel l as di gi tal modul ati on/demodul ati on. Thi s ter m r efer s to the di gi tal
sampl i ng ti me. Pl ease note that the symbol i nter val for the transmi tti ng si de
and the recei vi ng si de shoul d be exactl y the same to obtai n the corr ect r esul ts.
The par ameter Symbol interval can be a two-el ement vector , i n whi ch case the
second el ement i s ei ther:
the transmi tti ng offset ti me for a mappi ng bl ock
the deci si on offset ti me for a demappi ng bl ock
Usual l y, the transmi tti ng offset i s di ffer ent from the deci si on offset. The
di fference may be caused by di storti on, i nterference, fi l ter i ng and other
reasons i n the tr ansmi tti ng and recei vi ng pr ocess. I n the fi gur e bel ow, the
upper gr aph i s the tr ansmi tted si gnal ; the l ower graph i s the r ecei ved si gnal .
Note that the deci si on offset i s determi ned based on the character i sti cs of the
tr ansmi tti ng system. The eye-patter n pl ot i s useful i n determi ni ng the deci si on
offset. The uni t for both symbol i nter val and offset i s i n seconds.
Figure 6-19: The Symbol Interval and Its Offset in Transmission and Reception
Transmitting offset
Decision offset
Symbol interval
Symbol interval
T
r
a
n
s
m
i
t
t
i
n
g
R
e
c
e
i
v
i
n
g
6-211
Thi s tool box assumes the di gi ts i n the transmi tti ng ar e non-negati ve i nteger s.
The i nteger s i n the tr ansmi tti ng can be 0, 1, 2,..., M-1. Under these
assumpti ons, M i s cal l ed the M-ary number.
Passband and Baseband Digital
Mapping/ Demapping Reference Table
Thi s tabl e l i sts the Si mul i nk mappi ng and demappi ng bl ocks used i n both the
passband and baseband versi ons of the Di gi tal Mod/Demod Mappi ng/
Demappi ng subl i br ari es. (Thi s tabl e l i sts the bl ocks i n al phabeti cal order for
your conveni ence.):
Block Name Description
MASK Demap Mul ti pl e ampl i tude shi ft-keyi ng
(MASK) demappi ng
MASK Map Mul ti pl e ampl i tude shi ft-keyi ng
(MASK) mappi ng
MFSK Map Mul ti pl e fr equency shi ft-keyi ng
(MFSK) mappi ng
Mi n/Max Demap Mi ni mum/maxi mum demappi ng
QASK Demap Arbi tr ar y
Constel l ati on
Quadratur e ampl i tude shi ft-keyi ng
(QASK) demappi ng usi ng an
ar bi tr ary constel l ati on
QASK Demap Ci rcl e Constel l ati on Quadratur e ampl i tude shi ft-keyi ng
(QASK) demappi ng usi ng a ci r cl e
constel l ati on
QASK Demap Squar e Constel l ati on Quadratur e ampl i tude shi ft-keyi ng
(QASK) demappi ng usi ng a square
constel l ati on
QASK Map Arbi trar y Constel l ati on Quadratur e ampl i tude shi ft-keyi ng
(QASK) mappi ng usi ng an
ar bi tr ary constel l ati on
6-212
QASK Map Ci rcl e Constel l ati on Quadratur e ampl i tude shi ft-keyi ng
(QASK) mappi ng usi ng a ci r cl e
constel l ati on
QASK Map Square Constel l ati on Quadratur e ampl i tude shi ft-keyi ng
(QASK) mappi ng usi ng a square
constel l ati on
Block Name Description
MASK Map
6-213
6
6
MASK Map
Catagory Modul ati on Map
Location Di gi tal Mo/Dem Map/Demap Subl i brar y
Description The MASK (mul ti pl e ampl i tude shi ft-keyi ng) Map bl ock modul ates an i nput
message si gnal . MASK i s a one-di mensi onal codi ng scheme that codes i ntegers
as ampl i tude shi fts. A si gnal set for M-ar y numbers 2, 4, 8, and 16 i s:
Thi s bl ock assumes a maxi mum ampl i tude normal i zed to one; i f you r equi r e a
di ffer ent maxi mum val ue, pl ace a gai n bl ock after thi s bl ock.
Thi s bl ock i s a di scr ete-ti me bl ock; i t codes the i nput si gnal onl y at the
sampl i ng ti me poi nt. Ther e i s, however , a mechani sm pr ovi ded to convert
di gi tal si gnal s to anal og si gnal s. On account of thi s, the output si gnal of thi s
bl ock i s ready to use wi th anal og modul ati on bl ocks.
Dialog Box
Amplitude
-1 0 1
M=2
M=4
M=8
M=16
Speci fy the number of i nput symbol s. The
i nput symbol s ar e i n the i nteger r ange [0,M-1].
General l y M=2
K
, wher e K i s a posi ti ve i nteger .
The sampl e ti me each i nput symbol . When thi s
parameter i s a two-el ement vector , the second
el ement i s the offset val ue.
MASK Map
6-214
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block MASK Demap
Equivalent
M-function
modmap
MASK Demap
6-215
MASK Demap
Catagory Modul ati on Demap
Location Di gi tal Mo/Dem Map/Demap Subl i brar y
Description The MASK (mul ti pl e ampl i tude shi ft-keyi ng) Demap bl ock r ecover s a message
si gnal from a modul ated i nput si gnal . The par ameters set i n the di al og box of
thi s bl ock must match those used i n the cor respondi ng MASK Map bl ock to
obtai n the corr ect resul t.
Thi s bl ock i s the i nver se of the MASK Map bl ock. I t accepts a si gnal i n the [-1,
1] r ange and outputs a number i n the [0, M-1] r ange, wher e M i s the M-ar y
number that was used i n the MASK Map bl ock.
The MASK Demap bl ock i s a di screte-ti me bl ock and decodes the i nput si gnal
onl y at the sampl i ng ti me poi nts, but i t has a mechani sm to conver t anal og
si gnal s to di gi tal si gnal s. On account of thi s, i t i s possi bl e to connect thi s di gi tal
bl ock to anal og bl ocks.
Dialog Block
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block MASK Map
Equivalent
M-function
de modmap
Match these par ameter s to the ones i n the
cor r espondi ng MASK Map bl ock.
QASK Map Square Constellation
6-216
QASK Map
Square Constel l ati on
Catagory Modul ati on Map
Location Di gi tal Mo/Dem Map/Demap Subl i br ar y
Description The QASK (quadrature ampl i tude shi ft-keyi ng) Map Square Constel l ati on
bl ock converts an i nput message si gnal i nto a two di mensi onal codi ng si gnal .
For M-ar y number M equal to 4, 16, and 32, the square QASK constel l ati on i s:
The two axes are the i n-phase and quadratur e components of the mapped
si gnal . The mappi ng from the i nput i nteger to the components of the two axes
i s a one-to-one mappi ng. The maxi mum ampl i tude for both components i s 1;
use a gai n bl ock after thi s bl ock i f you requi re a di ffer ent maxi mum ampl i tude.
You can use the functi on qas ke nc o to pl ot squar e constel l ati ons.
Quadrature Amplitude
In-phase Amplitude
M=32
M=16
M=4
QASK Map Square Constellation
6-217
Dialog Box
Characteristics No. of I nputs/Outputs 1/2
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block QASK Demap Squar e Constel l ati on
Equivalent
M-function qas ke nc o for QASK squar e constel l ati on pl ot
Speci fy the i nput r ange. The i nput symbol s ar e i n
the i nteger r ange [0,M-1]. Gener al l y M=2
K
,
wher e K i s a posi ti ve i nteger.
The sampl e ti me of the i nput symbol . When thi s
parameter i s a two-el ement vector , the second
el ement i s the offset val ue.
QASK Demap Square Constellation
6-218
QASK Demap
Square Constel l ati on
Catagory Demodul ati on Demap
Location Di gi tal Mo/Dem Map/Demap Subl i br ar y
Description The QASK (quadrature ampl i tude shi ft-keyi ng) Demap Square Constel l ati on
bl ock recover s a message si gnal from two i nput si gnal s recei ved from the
cor respondi ng QASK Map Squar e Constel l ati on bl ock.
Dialog Box
Characteristics No. of I nputs/Outputs 2/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States N/A
Pair Block MASK Map Squar e Constel l ati on
Equivalent
M-function
de modmap
Match these par ameter s to the ones i n the
cor r espondi ng QASK Map bl ock.
QASK Map Circle Constellation
6-219
QASK Map
Ci rcl e Constel l ati on
Catagory Modul ati on Map
Location Di gi tal Mo/Dem Map/Demap Subl i brar y
Description The QASK (quadratur e ampl i tude shi ft-keyi ng) Map Ci rcl e Constel l ati on bl ock
converts an i nteger message si gnal i nto a two di mensi onal codi ng si gnal . The
constel l ati on of the si gnal set i s a sequence of one or more concentri c ci rcl es.
Defi ne the si gnal set by speci fyi ng the Number of symbols on each ci rcl e, the
Radii for each ci r cl e, and the Phase shift for each ci r cl e i n a set of thr ee
equal -l ength vector s.
You can gener ate a pl ot of the ci rcl e constel l ati on usi ng the functi on
modmap. For exampl e, defi ne the three vectors:
Numbe r _of _s y mbol = [ 4 12] ;
Radi i = [ 1 2] ;
Phas e _s hi f t = [ pi /4, 0] ;
Usi ng modmap, gener ate the pl ot of the constel l ati on:
modmap( ' qas k/c i r cl e' , Number _of _s y mbol s , . . . Radi i , Phas e _s hi f t ) ;
Dialog Box
The number of symbol s on each ci r cl e. The
el ements of thi s vector must be posi ti ve i nteger s.
The r adi us and phase shi ft for each ci r cl e. The
l ength of each of these vector s must equal the
l ength of the Number of symbols in each
circle vector .
The sampl e ti me of the i nput symbol . When thi s
parameter i s a two-el ement vector , the second
el ement i s the offset val ue.
QASK Map Circle Constellation
6-220
Characteristics No. of I nputs/Outputs 1/2
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block QASK Demap Ci r cl e Constel l ati on
Equivalent
M-function modmap for mappi ng computati on and constel l ati on pl ots
QASK Demap Circle Constellation
6-221
QASK Demap
Ci rcl e Constel l ati on
Catagory Demodul ati on Demap
Location Di gi tal Mo/Dem Map/Demap Subl i brar y
Description The QASK (quadrature ampl i tude shi ft-keyi ng) Demap Ci r cl e Constel l ati on
bl ock recovers a message si gnal from two i nput si gnal s recei ved fr om the
cor respondi ng QASK Map Ci rcl e Constel l ati on bl ock.
Dialog Box
Characteristics No. of I nputs/Outputs 2/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block MASK Map Ci rcl e Constel l ati on
Equivalent
M-function
de modmap
Match these par ameter s to the ones i n the
cor r espondi ng QASK Map bl ock. The offset for
the Symbol interval may di ffer .
QASK Map Arbitrary Constellation
6-222
QASK Map
Ar bi trar y Constel l ati on
Catagory Modul ati on Map
Location Di gi tal Mo/Dem Map/Demap Subl i br ar y
Description The QASK (quadratur e ampl i tude shi ft-keyi ng) Arbi trar y Constel l ati on bl ock
converts an i nput message i nto a two di mensi onal codi ng si gnal . The structure
of the constel l ati on i s user -defi ned.
Defi ne the poi nts of the constel l ati on by usi ng two equal l ength vector s; the
fi rst vector defi nes the i n-phase component of each constel l ati on poi nt, and the
second defi nes the quadrature component. The M-ary number M i s the total
number of poi nts defi ned i n the constel l ati on. M i s equal to the l ength of ei ther
of the two vectors.
You can gener ate a pl ot of the ar bi tr ary constel l ati on by usi ng the functi on
modmap:
modmap( ' qas k/ar b' , x, y) ;
Dialog Box
Defi ne the i n-phase and quadr atur e components
of each poi nt i n the constel l ati on.
The sampl e ti me of each i nput symbol . When thi s
par ameter i s a two-el ement vector , the second
el ement i s the offset val ue.
QASK Map Arbitrary Constellation
6-223
Characteristics No. of I nputs/Outputs 1/2
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block QASK Demap Arbi tr ar y Constel l ati on
Equivalent
M-function
modmap
QASK Demap Arbitrary Constellation
6-224
QASK Demap
Ar bi trar y Constel l ati on
Catagory Demodul ati on Demap
Location Di gi tal Mo/Dem Map/Demap Subl i br ar y
Description The QASK (quadrature ampl i tude shi ft-keyi ng) Demap Arbi trary
Constel l ati on bl ock recovers a message si gnal from two i nput si gnal s recei ved
from the corr espondi ng QASK Map Ar bi tr ary Constel l ati on bl ock.
Dialog Box
Characteristics No. of I nputs/Outputs 2/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block QASK Map Ar bi tr ar y Constel l ati on
Equivalent
M-function
de modmap
Match these par ameter s to the ones i n the
cor r espondi ng QASK Map bl ock. The offset val ue
i n Symbol interval may di ffer.
MFSK Map
6-225
MFSK Map
Catagory Modul ati on Map
Location Di gi tal Mo/Dem Map/Demap Subl i brar y
Description The MFSK (mul ti pl e frequency shi ft-keyi ng) Map bl ock codes an i nput si gnal
usi ng frequency shi ft-keyi ng.
The di scr ete i nput si gnal i s an i nteger i n the r ange [0, M-1], wher e M i s the
M-ar y number. Thi s bl ock r equi r es the defi ni ti on of a Tone space, whi ch i s a
scal ar that speci fi es the frequency separati on between two nei ghbori ng i nput
i ntegers. The modul ated si gnal has a fr equency i n the r ange
[Fc, Fc+B], wher e Fc i s the car ri er fr equency and B i t the bandwi dth of MFSK.
Note that
B=( M- 1) t one _s pac e
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block MFSK Cor rel ati on Demod and Mi n/Max Demap
Equivalent
M-function
modmap
The frequency separati on between two
nei ghbor i ng i nput i nteger s. The Tone space
i s al so known as the frequency separation.
The sampl e ti me of the i nput symbol . When thi s
parameter i s a two-el ement vector , the second
el ement i s the offset val ue.
Min/ Max Demap
6-226
Mi n/Max Demap
Catagory Demodul ati on Demap
Location Di gi tal Mo/Dem Map/Demap Subl i br ar y
Description The Mi n/Max Demap bl ock fi nds the mi ni mum or maxi mum el ement of an
i nput vector and outputs (i ndex - 1), where i nde x i s the i ndex of the el ement.
You can use thi s bl ock for both MFSK and MPSK mappi ng.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs Yes/No
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
The sampl e ti me for the output di gi t. When thi s
par ameter i s a two-el ement vector , the second
el ement i s the offset val ue.
A str i ng entr y. Choose whether to eval uate for
the maxi mum or mi ni mum el ement.
Coherent MFSK Corr Demod
6-227
Coher ent MFSK
Corr Demod
Catagory Corr el ati on Cal cul ati on
Location Di gi tal Mo/Dem Map/Demap Subl i brar y
Description The Coherent MFSK (mul ti pl e frequency shi ft-keyi ng) Cor r Demod bl ock
cal cul ates the cor rel ati on between the i nput si gnal and a vector of si nusoi dal
si gnal s usi ng the coher ent recover y method.
Thi s bl ock cal cul ates the cor rel ati on between the i nput si gnal and a vector of
si nusoi dal si gnal s of var i ous frequenci es. Each si nusoi dal i n the vector
cor responds to a possi bl e demappi ng val ue. The fi gur e bel ow show the coherent
cor rel ati on MFSK demodul ati on method:
Figure 6-20: Block Diagram of Coherent MFSK Correlation Demodulation
X
X
X
cos(2f
c
t+)
cos(2(f
c
+f)t+)
cos(2(f
c
+(M1)f)t+)
Received Signal
Max
Demap
Decision
Digit
( ) t d
kT
k 1 + ( )T

( ) t d
kT
k 1 + ( )T

( ) t d
kT
k 1 + ( )T

Coherent MFSK Corr Demod


6-228
The functi onal i ty of thi s bl ock i s i nsi de the dashed box. Par ameter f
c
i s the
car ri er fr equency, f i s the tone space, and i s the i ni ti al phase of the
demodul ati on. M i s the M-ary number, and T i s the i ntegrati on ti me i nterval .
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/Yes
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block FM wi th i ts si gnal i nput from MFSK Map
Equivalent
M-function
comdemod
Speci fy the possi bl e r ange of the i nput symbol s.
The r ange i s [0, M-1].
The fr equency separ ati on between nei ghbor i ng
i nput symbol s.
The sampl e ti me of the transmi tted symbol .
When thi s parameter i s a two-el ement vector , the
second el ement i s the offset val ue. Thi s par am-
eter deter mi nes the i ntegr ati on ti me i nterval T of
the cor r el ati on functi on.
The fr equency of the car r i er si gnal .
The i ni ti al phase of the car r i er si gnal .
The cal cul ati on sampl e ti me. By the
Nyqui st sampl i ng theorem,
1/s ampl e _t i me > 2car r i e r _f r eque ncy .
Noncoherent MFSK Corr Demod
6-229
Noncoh erent MFSK
Corr Demod
Catagory Corr el ati on Cal cul ati on
Location Di gi tal Mo/Dem Map/Demap Subl i brar y
Description The Noncoher ent MFSK Cor r Demod (mul ti pl e fr equency shi ft-keyi ng
cor rel ati on demodul ati on) bl ock cal cul ates the corr el ati on between the i nput
si gnal and a vector of si nusoi dal si gnal s usi ng the noncoherent method.
Thi s bl ock cal cul ates the cor rel ati on between the i nput si gnal and a vector of
si nusoi dal si gnal s of var i ous frequenci es. Unl i ke the Coherent MFSK
Corr el ati on method, thi s method i s i nsensi ti ve to i ni ti al phase vari ati ons. The
tr ade-off i s that the cal cul ati on of the noncoherent corr el ati on takes about
twi ce as much ti me as that i n the coherent demodul ati on bl ock.
Noncoherent MFSK Corr Demod
6-230
The di agram bel ow shows the noncoher ent cor rel ati on MFSK demodul ati on
method:
Figure 6-21: Block Diagram of Noncoherent MFSK Correlation Demodulation
X
X
X
cos(2f
c
t+)
cos(2(f
c
+f)t+)
cos(2(f
c
+(M1)f)t+)
Received Signal
Max
Demap
Decision
Digit
( ) t d
kT
k 1 + ( )T

2
( ) t d
kT
k 1 + ( )T

2
+
sin(2f
c
t+)
( ) t d
kT
k 1 + ( )T

2
sin(2(f
c
+f)t+)
X
( ) t d
kT
k 1 + ( )T

2
+
X
( ) t d
kT
k 1 + ( )T

2
sin(2(f
c
+(M1)f)t+)
X
( ) t d
kT
k 1 + ( )T

2
+
Noncoherent MFSK Corr Demod
6-231
The functi onal i ty of the bl ock i s i nsi de the dashed box. Parameter f
c
i s the
carr i er fr equency, f i s the tone space, and the i ni ti al phase i n the
demodul ati on. M i s the M-ary number , and T i s the i ntegrati on ti me i nterval .
Thi s bl ock accepts a scal ar i nput and outputs a vector of corr el ati on val ues.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/Yes
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block FM bl ock and MFSK Map bl ock
Equivalent
M-function
comde mod
Speci fy the possi bl e range of the i nput symbol s.
The r ange i s [0, M-1].
The frequency separati on between nei ghbori ng
i nput symbol s.
The sampl e ti me of the tr ansmi tted symbol .
When thi s par ameter i s a two-el ement vector ,
the second el ement i s the offset val ue. Thi s
parameter deter mi nes the i ntegr ati on ti me
i nter val T of the corr el ati on functi on.
The frequency of the car r i er si gnal .
The i ni ti al phase of the car r i er si gnal .
The cal cul ati on sampl e ti me. By the
Nyqui st sampl i ng theor em,
1/s ampl e_t i me > 2car r i e r _f r e quency .
MPSK Map
6-232
MPSK Map
Catagory Modul ati on Map
Location Di gi tal Mo/Dem Map/Demap Subl i br ar y
Description The MPSK (mul ti pl e phase shi ft-keyi ng) Map bl ock conver ts an i nteger si gnal
i nto a coded si gnal usi ng the MPSK method. The di scr ete i nput si gnal must be
i n the range [0, M1], wher e M i s the M-ar y number. The phase shi ft for i nput
symbol i i s 2i/ M
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block MPSK Corr el ati on Demod bl ock and Mi n/Max Demap bl ock
Equivalent
M-function
modmap
Speci fy the r ange of the i nput symbol s. The r ange
i s [0, M-1].
The sampl e ti me of the tr ansmi tted di gi t symbol .
When thi s parameter i s a two-el ement vector , the
second el ement i s the offset val ue.
MPSK Correlation Demodulation
6-233
MPSK Corr el ati on
Demodu l ati on
Catagory Corr el ati on Cal cul ati on
Location Di gi tal Mo/Dem Map/Demap Subl i brar y
Description The MPSK (mul ti pl e phase shi ft-keyi ng) Cor rel ati on Demodul ati on bl ock
cal cul ates the cor rel ati on between an i nput si gnal and a vector of carr i er
frequency si nusoi dal si gnal s, al l of whi ch have the same frequency but vary i n
phase. The fi gur e bel ow shows the MPSK cor rel ati on demodul ati on method:
Figure 6-22: Block Diagram of MPSK Correlation Demodulation
The functi onal i ty of the bl ock i s i nsi de the dashed box. Parameter f
c
i s the
carr i er fr equency, and
i
i s the i ni ti al phase for di gi t i.
Thi s bl ock accepts a scal ar i nput and outputs a vector of corr el ati on val ues.
X
X
X
cos(2f
c
t+
0
)
cos(2f
c
t+
1
)
cos(2f
c
t+
1
)
Received Signal
Max
Demap
Decision
Digit
( ) t d
kT
k 1 + ( )T

( ) t d
kT
k 1 + ( )T

( ) t d
kT
k 1 + ( )T

MPSK Correlation Demodulation


6-234
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/Yes
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block MFSK Corr el ati on Demod bl ock and Mi n/Max Demap bl ock
Equivalent
M-function
modmap
Speci fy the possi bl e r ange of the i nput symbol s.
The r ange i s [0, M-1].
The sampl e ti me of the tr ansmi tted di gi t symbol .
When thi s parameter i s a two-el ement vector , the
second el ement i s the offset val ue.
The fr equency of the car r i er si gnal .
The i ni ti al phase of the car r i er fr equency.
The cal cul ati on sampl e ti me. By the
Nyqui st sampl i ng theorem,
1/s ampl e _t i me > 2car r i e r _f r eque ncy .
6-235
6
Signal Multiple Access
Most modern communi cati on transmi tti ng resources are shar ed by mul ti pl e
user s. Si gnal mul ti pl e access i s a techni que to share fi xed communi cati on
resources by mul ti pl e user s. A typi cal mul ti pl e access communi cati on system
i s shown i n the fi gur e bel ow. The mul ti pl e access bl ock on the tr ansmi tti ng si de
col l ects al l i nfor mati on to be tr ansfer red and sends the i nfor mati on through
the tr ansmi tti ng channel . The mul ti pl e access bl ock on the r ecei vi ng si de
recovers the i ndi vi dual si gnal s and di vi des the si gnal s i nto the i ndi vi dual
recei vers.
Figure 6-23: A Typical Multiple Access Communication System
The tool box i ncl udes four di ffer ent mul ti -access techni ques:
Ti me-share mul ti pl ex
TDMA (ti me di vi si on mul ti pl e access)
FDMA (fr equency di vi si on mul ti pl e access)
CDMA (code di vi si on mul ti pl e access)
The Ti me-shari ng mul ti pl ex techni que i s used for anal og si gnal s. TDMA i s
used wi th di scr ete i nformati on sequences. The Vector Di str i butor bl ock i s
provi ded as a basi c uti l i ty for constr ucti ng TDMA bl ocks.
FDMA uses modul ati on techni ques. As di scussed i n the Modul ati on and
Demodul ati on secti on of thi s chapter , ther e i s mor e than one way to modul ate
Transmitter 1
Transmitter 2
Transmitter 3
Transmitter N
Receiver 1
Receiver 2
Receiver 3
Receiver M
Multiple
Access
Multiple
Access
Channel
6-236
a si gnal . The mul ti pl e access subl i brar y gi ves an exampl e for the FDMA
techni que. You can use the exampl e to i mpl ement your own FDMA systems.
The same i s true for the CDMA. A fr equency hoppi ng CDMA exampl e i s
provi ded i n the mul ti pl e access subl i br ary to i l l ustr ate how to use the avai l abl e
bl ocks to bui l d a transmi tti ng system wi th CDMA.
Thi s fi gure shows the Mul ti pl e Access Subl i brar y:
Figure 6-24: Multiple Access Sublibrary
6-237
Multiple Access Reference Table
Thi s tabl e l i sts the Si mul i nk bl ocks i n the Mul ti pl e Access Subl i brar y.
(Thi s tabl e l i sts the bl ocks i n al phabeti cal or der for your conveni ence.):
Block Name Description
Ti me-Shar e Demux Ti me-Shar i ng demul ti pl exi ng
recovers N anal og si gnal s (N1)
from one anal og i nput si gnal
Ti me-Shar e Mux Ti me-Shar i ng mul ti pl exi ng r outes a
si ngl e anal og i nput to N (N1)
anal og output si gnal s
D-TDMA Demux Di gi tal ti me di vi si on mul ti pl e access
demul ti pl exi ng r ecover s N di gi tal
si gnal s (N1) fr om one di gi tal i nput
si gnal
D-TDMA Mux Di gi tal ti me di vi si on mul ti pl e access
mul ti pl exi ng routes a si ngl e di gi tal
i nput to N (N1) di gi tal output
si gnal s
Vector Redi stri butor Redi str i butes el ements fr om i nput
vectors to output vectors i n a
speci fi ed rear rangement scheme
D-TDMA Mux
6-238
6
D-TDMA Mux
Catagory Ti me Di vi si on Mul ti pl e Access
Location Mul ti pl e Access Subl i brar y
Description The D-TDMA (di gi tal ti me di vi si on mul ti pl e access) Mux bl ock takes N (N>1)
si gnal s and generates a si gnal output si gnal usi ng mul ti pl exi ng. I t di vi des a
si ngl e transmi ssi on ti me per i od i nto ti me-shar i ng secti ons. Each transmi tted
si gnal takes one of the ti me-shari ng secti ons i n the tr ansmi ssi on. Duri ng the
ti me i n whi ch one si gnal has access to the mul ti pl exer , the other si gnal s are
deni ed access.
Thi s bl ock accepts a l ength N vector i nput (N>1) and outputs a scal ar si gnal .
Each i nput si gnal shar es a sampl e ti me t
s
. The D-TDMA Mux bl ock sampl es
each i nput si gnal i n tur n duri ng the t
s
ti me i nterval . The output has sampl i ng
ti me t
s
/N.
The fi gur e bel ow depi cts the D-TDMA Mul ti pl ex process:
Figure 6-25: Digital TDMA Multiplexing
I n thi s exampl e, the D-TDMA mul ti pl exer sampl es si gnal s 1, 2, and 3 i n tur n
and outputs one composi te si gnal . The bl ock sampl es the fi rst el ement of the
i nput vector at ti me t
0
, the second el ement at ti me (t
0
+ t
s
/3), and the thi r d
el ement at ti me (t
0
+ 2t
s
/3).
D-TDMA
Mux
t0 t1 t2 t3 t4
t0+d1 t1+d1 t2+d1 t3+d1
t0+d2 t1+d2 t2+d2 t3+d2
t0 t1 t2 t3 t4
signal 1
signal 2
signal 3
output
D-TDMA Mux
6-239
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs Yes/No
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block D-TDMA Demux
The sampl e ti me t
s
of the i nput si gnal s.
Speci fy the l ength of the i nput vector .
D-TDMA Demux
6-240
D-TDMA Demu x
Catagory Ti me Di vi si on Mul ti pl e Access
Location Mul ti pl e Access Subl i brar y
Description The D-TDMA (di gi tal ti me di vi si on mul ti pl e access) Demux bl ock r ecover s N
(N>1) di gi tal si gnal s fr om one i nput di gi tal si gnal usi ng demul ti pl exi ng. Thi s
bl ock assumes that the i nput si gnal i s the output of the D-TDMA Mux bl ock.
Thi s bl ocks accepts a scal ar i nput and outputs N di gi tal si gnal s. Each i nput
si gnal shares a sampl e ti me t
s
/N. The D-TDMA Demux bl ock sampl es each
i nput si gnal i n tur n dur i ng the t
s
ti me i nterval . The output has sampl i ng
ti me ts.
The fi gur e bel ow depi cts the D-TDMA Demul ti pl ex process:
Figure 6-26: Digital TDMA Demultiplexing
Each r ecover ed si gnal i s a sampl ed output from the i nput si gnal . d1 and d2 are
offset val ues; here d1 = t
s
/3 and d2 = 2t
s
/3. I n general , di = i t
s
/N, where i
ranges from 1 to N1.
D-TDMA
Demux
t0 t1 t2 t3 t4
t0+d1 t1+d1 t2+d1 t3+d1
t0+d2 t1+d2 t2+d2 t3+d2
t0 t1 t2 t3 t4
signal 1
signal 2
signal 3
input
D-TDMA Demux
6-241
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/Yes
Ti me Base Di scr ete ti me
States N/A
Di r ect Feedthrough Yes
Pair Block D-TDMA Mux
Match these par ameter s to the ones used i n the
cor r espondi ng D-TDMA Mux bl ock.
Time-Share Mux
6-242
Ti me-Shar e Mu x
Catagory Ti me Di vi si on Mul ti pl e Access
Location Mul ti pl e Access Subl i brar y
Description The A-TDMA (anal og ti me di vi si on mul ti pl e access) Mux bl ock takes N (N>1)
anal og si gnal s and generates a si ngl e output anal og si gnal usi ng mul ti pl exi ng.
I t di vi des a si ngl e tr ansmi ssi on ti me peri od i nto ti me-shari ng secti on; each
transmi tted si gnal takes one of the ti me-shari ng secti ons i n the tr ansmi ssi on
i n turn.
Thi s bl ocks accepts a l ength N vector i nput (N>1) and outputs a scal ar si gnal .
Each i nput si gnal shar es a sampl e ti me t
s
. The D-TDMA Mux bl ock sampl es
each i nput si gnal i n tur n duri ng the t
s
ti me i nterval . The output has sampl i ng
ti me t
s
/N.
The fi gur e bel ow depi cts the A-TDMA Mul ti pl ex pr ocess:
Figure 6-27: Analog TDMA Multiplexing
A-TDMA
Mux
output
t0
t1
t2
t0+d1 t1+d1
t0+d2 t1+d2
signal 1
signal 2
signal 3
t0
t1
t2
Time-Share Mux
6-243
I n thi s exampl e, the A-TDMA mul ti pl exer sampl es si gnal s 1, 2, and 3 i n turn
and outputs one composi te si gnal . The bl ock sampl es the fi rst el ement of the
i nput vector at ti me t
0
, the second el ement at ti me (t
0
+ t
s
/3), and the thi r d
el ement at ti me (t
0
+ 2t
s
/3).
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs Yes/No
Ti me Base Mi xed
States N/A
Di r ect Feedthrough Yes
Pair Block A-TDMA Demux
The sampl e ti me t
s
of the i nput si gnal s.
Speci fy the l ength of the i nput vector .
Time-Share Demux
6-244
Ti me-Shar e Demux
Catagory Ti me Di vi si on Mul ti pl e Access
Location Mul ti pl e Access Subl i brar y
Description The Ti me-Shar e Demux bl ock recovers N (N>1) di gi tal si gnal s fr om one i nput
di gi tal si gnal usi ng demul ti pl exi ng. Thi s bl ock assumes that the i nput si gnal
i s the output of the D-TDMA Mux bl ock.
Thi s bl ocks accepts a scal ar i nput and outputs N di gi tal si gnal s. Each i nput
si gnal shares a sampl e ti me t
s
. The D-TDMA Mux bl ock sampl es each i nput
si gnal i n turn dur i ng the t
s
ti me i nter val . The output has sampl i ng ti me
ts/N.
The fi gur e bel ow depi cts the D-TDMA Mux pr ocess:
Figure 6-28: Analog TDMA Demultiplexing
Each r ecover ed si gnal i s a sampl ed output from the i nput si gnal . d1 and d2 are
offset val ues; here d1 = t
s
/3 and d2 = 2t
s
/3. I n general , di = i t
s
/N, where i
ranges from 1 to N1.
A-TDMA
Demux
output
t0
t1
t2
t0+d1 t1+d1
t0+d2 t1+d2
signal 1
signal 2
signal 3
t0
t1 t2
Time-Share Demux
6-245
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/Yes
Ti me Base Mi xed
States N/A
Di r ect Feedthrough Yes
Pair Block A-TDMA Mux
Match these par ameter s to those used i n the
cor r espondi ng Ti me-Shar e Mux bl ock.
Vector Redistributor
6-246
Vector Redi str i butor
Catagory Uti l i ty
Location Mul ti pl e Access Subl i brar y
Description The Vector Redi sti butor bl ock rear ranges N i nput si gnal s i nto M output
si gnal s. Both N and M ar e posi ti ve i nteger s. Thi s bl ock i s a gener al i zati on of
the Ti me-Shar e Mux and Ti me-Shar e Demux bl ocks. The i nput and output
si gnal s can be any combi nati on of anal og and di gi tal si gnal s.
The fi gure bel ow i s an exampl e of a vector redi stri buti on of three i nput si gnal s
to two output si gnal s:
Figure 6-29: Vector Redistribution of Three Input Signals to Two Output
signals
Vector
Redis-
Output 1
Input 1
Input 2
Input 3
t0
t2
Output 2
t1 t3 t4
Trigger signal
Threshold
t0
t2 t1 t3 t4
t0
t2 t1 t3 t4
t0
t2 t1 t3 t4
tribution
Vector Redistributor
6-247
I nput por t 1 accepts a l ength N vector, where N i s the number of i nput si gnal s
that the bl ock r edi str i butes. I nput por t 2 accepts a scal ar tr i gger si gnal ; the
rai si ng edge of the tr i gger si gnal s tr i gger s the bl ock to r earr ange the order of
the i nput si gnal . I n the exampl e above, the tri gger s occur at t1, t2, and t3. The
output of thi s bl ock i s a l ength M si gnal , wher e M>1. N and M do not have to
be equal .
The rearr angement patter n i s defi ned i n the Switch box par ameter, whi ch i s
a matri x wi th M col umns. The number of rows i s arbi tr ar y. When the fi r st
tr i gger occurs, the Vector Redi str i butor bl ock uses the fi rst col umn of the
Swi tch box to rear range the i nput vector si gnal . When the second tri gger
occur s, the bl ock uses the second row of the Switch box to r earr ange the i nput
vector. Thi s pr ocess conti nues unti l the bl ock exhausts al l the r ows avai l abl e.
At that poi nt the pr ocess starts agai n wi th the fi rst r ow.
For the exampl e above, the swi tch box matri x i s:
s wi t c h_box = [ 1 3; 3 1; 2 2; 3 3] ;
Assume that the fi rst tri gger has occurr ed. Then the val ues i n the fi rst r ow
defi ne the rear rangement. The r ul e i s that the i th col umn i nput val ue goes to
the output speci fi ed i n the i th col umn of the fi rst r ow. I n thi s case, i t means
the i nput vector el ement 1 goes to output 1, and i nput vector el ement 3 goes to
output 2. I n the second r ow, the rear rangement r ul e speci fi es that i nput vector
el ement 3 goes to output 1, and i nput vector el ement 1 goes to output 2.
I f a 0 i s entered i n the i th el ement of the rear rangement r ow, the bl ock i nspects
the Keeping value parameter at that i ndex to determi ne whether the i th
output i s hel d at i ts l ast val ue or r eset to i ts i ni ti al val ue. For exampl e, i f
i nstead of [1 3] i n the fi r st row we had pl aced [0 3], the Vector Redi str i butor
bl ock woul d check the fi rst el ement of the Keeping value vector. I f that
el ement i s gr eater than or equal to 0, output 1 i s hel d at the l ast val ue i t had
dur i ng the pr evi ous tr i gger . I f that el ement i s a negati ve number , the Vector
Redi str i butor bl ock sets output 1 to the i ni ti al val ue as speci fi ed i n the Initial
Value vector .
Vector Redistributor
6-248
Dialog Box
Characteristics No. of I nputs/Outputs 2/1
Vector i zed I nput Yes
Vector i zed I nput 2 No
Vector i zed Output Yes
Ti me Base Auto
States N/A
Di r ect Feedthrough Yes
Speci fy the r earr angement patter n. Al l el ements
of the Switch box matr i x must be i n the range
[0, N-1].
A l ength N vector that speci fi es whether the
output defaul ts to the l ast hel d val ue or r esets to
i ts i ni ti al val ue. The test onl y occur s i f the
Switch box has a 0 entry i n the r ear range-
ment patter n.
A l ength N vector that speci fi es the output val ue
pr i or to the fi rst tr i gger occur ence.
Speci fy the val ue that, once cr ossed fr om bel ow,
for ces a tr i gger .
6-249
6
Transmitting and Receiving Filters
Befor e a si gnal i s sent out to a tr ansmi ssi on channel , or after a si gnal i s
recei ved fr om a transmi ssi on channel , fi l ter s are usual l y i nvol ved. For
exampl e, bandpass fi l ter s may be needed for a frequency shar i ng channel ;
l owpass fi l ter s may be needed for a whi te noi se channel ; a matched fi l ter may
be needed for a fadi ng channel .
The Tr ansmi tti ng/Recei vi ng Fi l ter Subl i br ary pr ovi des l owpass fi l ter s,
hi ghpass fi l ter s, bandpass fi l ter s and bandstop fi l ter s. Both anal og and di gi tal
fi l ters are i ncl uded. The fi l ter types can be Butterwor th fi l ter s, Chebychev type
I or type I I fi l ters, or el l i pti c fi l ter s. Mor e fi l ter s can be found i n the Fi l ter s
subl i br ary i n the DSP Bl ockset. The DSP Bl ockset i s recommended but not
requi red to use thi s tool box.
Thi s fi gure shows the Tr ansmi tti ng/Recei vi ng Fi l ter Subl i br ary:
Figure 6-30: Transmitting/ Receiving Filter Sublibrary
6-250
Transmitting/ Receiving Filters Reference Table
Thi s tabl e l i sts the Si mul i nk bl ocks i n the Transmi tti ng/Recei vi ng Fi l ter s
Subl i br ary. (Thi s tabl e l i sts the bl ocks i n al phabeti cal or der for your
conveni ence.):
Block Name Description
Compl ex Fi l ter I mpl ements I I R and FI R fi l ter wi th
compl ex par ameters
Hi l bert Fi l ter I mpl ements a Hi l bert fi l ter
Rai sed Cosi ne Fi l ter I mpl ements a rai sed cosi ne fi l ter
Si nc Outputs the zer o-cr ossi ng val ue of
an i nput si gnal when tri ggered
Raised Cosine Filter
6-251
6
Rai sed Cosi ne
Fi l ter
Catagory Fi l teri ng
Location Transmi tti ng and Recei vi ng Fi l ter s Subl i brary
Description The Rai sed Cosi ne Fi l ter bl ock i mpl ements a rai sed cosi ne fi l ter. I n di gi tal
tr ansmi ssi on, di gi tal si gnal s are represented by step waves. A step wave has
i nfi ni te bandwi dth. I n nar row band tr ansmi ssi on, the bandwi dth i s a cr i ti cal
i ssue. The spectr um of a step wave spr eads over a wi de range of frequency
domai ns. To restri ct the spectr um of the source si gnal , an R-C (r ai sed cosi ne)
fi l ter i s commonl y used. The tr ansfer functi on H(f) of an R-C fi l ter i s
where r i s the rol l off factor and T i s the ti me i nter val of the di gi tal message.
After a di gi tal si gnal passes an R-C fi l ter , the fr equency of the si gnal i s l i mi ted
i n the band [-W, W], where . The ti me r esponse h(t) of the fi l ter equal s:
H f ( )
T i f 0 f
1 r
2T
----------
T
2
---- 1
T
r
------- f
1 r
2T
----------
,
_
,
_
cos + i f
1 r
2T
---------- f
1 r +
2T
----------
0 i f
1 r +
2T
---------- f

'

=
W
1
2T
------- >
h t ( )
si nc
t
T
----
,
_

rt
T
--------
,
_
cos
1 4
r
2
t
2
T
2
-----------
------------------------------------------- =
Raised Cosine Filter
6-252
The ti me i mpul se response and the fr equency r esponse of the R-C fi l ter for r =0,
0.5, 1 are shown i n the fi gure bel ow. Note that the ti me domai n i mpul se
response of the fi l ter shown i n the upper pl ot of the fi gure di spl ays onl y thr ee
taps. I n theory, the taps extends to +/ i nfi ni ty.
Figure 6-31: Time and Frequency Responses of the R-C Filter
2 1 0 1 2
r = 0
r = 0.5
r = 1
Time Response
0.8 0.6 0.4 0.2 0 0.2 0.4 0.6
Frequency Response
r =
r =
r =
Raised Cosine Filter
6-253
I n some appl i cati ons, the R-C fi l ter i s di vi ded i nto two parts, one for the
tr ansmi tti ng si de and one for the recei vi ng si de. I n thi s case, each si de i s the
square r oot of the R-C fi l ter.The i mpul se r esponse of a squar e-root R-C fi l ter i s:
A Rai sed Cosi ne fi l ter i s a noncausal fi l ter . I n practi cal desi gn, the
i mpl ementati on of a noncausal fi l ter i s i mpossi bl e because a noncausal fi l ter
depends on futur e i nfor mati on. To sol ve thi s probl em, thi s tool box has
ar ti fi ci al l y added a ti me del ay to the fi l ter i n the i mpl ementati on. The ti me
del ay i s usual l y T mul ti pl i ed by a posi ti ve i nteger.
By defaul t, an R-C fi l ter takes a di gi tal pul se si gnal wi th the nonzer o pul se
wi th i ts one sampl e step pul se wi dth. When the i nput si gnal has i ts nonzero
pul se l onger than one R-C fi l ter sampl e step, a 1/si nc fi l ter shoul d be added to
tr uncate the pul se wi dth. I n thi s bl ock, the par ameter With or without sinc
filter speci fi es whether a 1/si nc fi l ter shoul d be appl i ed to the i nput si gnal . I n
gener al , the appl i cati on of a 1/si nc fi l ter i s suggested.
There i s one case, however , when 1/si nc shoul d not be used. When the R-C fi l ter
i s br oken i nto two squar e-r oot R-C fi l ters, do not appl y a 1/si nc fi l ter to the
second R-C.
h t ( )
4r
T
-----------
1 r + ( )
t
T
----
,
_
cos
1 r ( )
t
T
----
,
_
si n
4r
t
T
----
------------------------------------ +
1 4r
t
T
----
,
_
2

,
_
----------------------------------------------------------------------------- =
Raised Cosine Filter
6-254
Example The fi gure bel ow i s a exampl e of usi ng the R-C fi l ters to pr ocess an i nput si gnal .
The three si gnal s outputted to the scope ar e the or i gi nal di gi tal si gnal , one R-C
fi l ter fi l ter ed si gnal , and two cascaded squar e-root R-C fi l ter s fi l tered si gnal .
Figure 6-32: Time Response and Frequency Response of the R-C Filter
The di gi tal si gnal source repeatedl y outputs the sequence [-1 0 1 2 3 1] at
di gi tal durati on ti me 0.1 second. Al l R-C fi l ter s use computati on sampl e ti me
0.01, rol l off factor 0.5, and an FI R fi l ter . The R-C fi l ter i n the mi ddl e uses
normal R-C fi l ter wi th del ay step as 6. The two bottom R-C fi l ter s use
square-root R-C fi l ter wi th del ay step as 3. The l eft si de squar e-r oot R-C fi l ter
uses 1/si nc fi l ter ; the r i ght si de R-C fi l ter does not. Because the two square-root
R-C fi l ters ar e cascaded, the del ay for the two fi l ter s together i s si x del ay steps.
The fi gur e bel ow i s a snapshot of the scope. The dashed l i ne shows the di gi tal
i nput si gnal , whi ch i s the stai r step cur ve. The dotted l i ne i s the output of a
si ngl e normal R-C fi l ter. The sol i d curve i s the output of the two squar e-r oot
R-C fi l ters. Because the two fi l tered si gnal s are very cl ose i n val ue, the dotted
and dashed l i nes over l ay each other and can barel y be di sti ngui shed. Both
si gnal s have si x steps of del ay from the ori gi nal si gnal .
Sampled
read
variable
Sampled read
Mux
Mux
Scope
RC
Filter
Sqrt RC filter
w/o 1/sinc flt
RC
Filter
Sqrt RC filter
RC
Filter
RC filter
Raised Cosine Filter
6-255
Figure 6-33: Original vs. RC-Filtered Signals
Dialog Box
0 0.5 1 1.5 2 2.5 3
1
0.5
0
0.5
1
1.5
2
2.5
3
3.5
Time (second)
The dur ati on per i od for each tr ansfer r ed di gi t.
The cal cul ati on sampl i ng ti me. Thi s val ue must
be l ess that the dur ati on of di gi t. Typi cal l y, the
r ati o of these two par ameters i s an i nteger .
The r ol l off factor r . Set thi s par ameter to a val ue
between 0 and 1 i ncl usi ve.
Set thi s to a posi ti ve i nteger . The actual del ay
ti me i s del ay_stepsymbol _i nter val .
A stri ng var i abl e i nput. Speci fy ei ther ' FI R' or
' I I R' and ' Nor mal ' or ' Sqr t ' .
Set to 1 i f you r equi r e a 1/si nc fi l ter and 0 other -
wi se.
Raised Cosine Filter
6-256
Characteristics No. of I nputs 1
No. of Output 1
Vector i zed I nput No
Vector i zed Outputs No
Ti me Base Di scr ete ti me
States N/A
Di r ect feedthrough Yes
Sinc
6-257
Si n c
Catagory Fi l ter
Location Transmi tti ng and Recei vi ng Fi l ter s Subl i brary
Description The Si nc bl ock outputs the zero-crossi ng val ue duri ng one sampl e i nter val
when tr i gger ed by the r ai si ng edge of the tri gger si gnal . The transfer functi on
of thi s bl ock i s a si nc functi on
The ti me domai n i mpul se response of thi s bl ock i s an uni t wi dth squar e pul se.
The pul se wi dth uni t i s speci fi ed i n the Holding time (t
s
) par ameter.
Thi s bl ock has two i nput ports and one i nput port. I nput port 1 accepts the
si gnal . I nput port 2 takes the tri gger si gnal . The fi gur e bel ow shows an
exampl e of thi s bl ock:
Figure 6-34: The Functionality of the Sinc Block
Thi s bl ock i s used i n constr ucti ng the Rai sed Cosi ne Fi l ter bl ock.
si nc f ( )
f ( ) si n
f
------------------ t 0
1 t 0 =

'

=
1
sinc
t0 t1 t2
t0 t1 t2
t0 t1
t2
Input signal
Trigger signal
Output signal
t
s
Threshold
Sinc
6-258
Dialog Box
Characteristics No. of I nputs 1
No. of Output 1
Vector i zed I nput No
Vector i zed Outputs No
Ti me Base Auto
States N/A
Di r ect feedthrough Yes
The amount of ti me for the output pul se per i od.
The threshol d for detecti ng the rai si ng edge of the
tri gger si gnal . When thi s entr y i s zer o, the bl ock
outputs the i nput si gnal of the fi r st i nput si gnal
and the tr i gger si gnal i s i gnor ed.
Hilbert Filter
6-259
Hi l ber t Fi l ter
Category Fi l ter
Location Transmi tti ng and Recei vi ng Fi l ter s Subl i brary
Description The Hi l ber t Fi l ter bl ock i mpl ements a Hi l bert tr ansfer fi l ter . The Hi l bert
tr ansfor m fi l ter has the tr ansfer functi on
whi ch has the i mpul se r esponse
As di scussed i n the Tutor i al Chapter , a Hi l bert tr ansfer fi l ter i s a noncausal
fi l ter. To i mpl ement a noncausal fi l ter, a ti me del ay i s added arti fi ci al l y. To use
thi s bl ock, you must speci fy the bandwi dth of the i nput si gnal , the ti me del ay
(DLY), and computati on sampl e ti me (TS). We encour age you to use the
MATLAB functi on hilbiir to test the parameter s to be used i n the bl ock. For an
accur ate cal cul ati on, the parameter s shoul d be chosen such that DLY i s at
l east a few ti mes l arger than ST, and rem(DLY, ST) = ST/2.
Pl ease be aware that when you i nput a si gnal bandwi dth exceeded the
bandwi dth par ameter, thi s bl ock may output unexpected r esul t.
Dialog Box
Equivalent
M-function hi l bert i n Si gnal Processi ng Tool box
H f ( ) j f ( ) sgn =
h t ( )
1
t
----- =
The upper l i mi t of the bandwi dth of the i nput
si gnal .
The ti me del ay of the Hi l bert tr ansform fi l ter (i n
second).
The sampl e ti me of the Hi l bert fi l ter .
Complex Filter
6-260
Compl ex
Fi l ter
Catagory Fi l ter
Location Uti l i ty Subl i brar y
Description The Compl ex Fi l ter bl ock i mpl ements both i nfi ni te i mpul se r esponse (I I R) and
fi ni te i mpul se r esponse (FI R) fi l ters. Thi s bl ock accepts a r eal or a compl ex
i nput si gnal and outputs a compl ex si gnal . The numer ator and denomi nator
are compl ex vectors that represent the coeffi ci ents of the fi l ters transfer
functi on. The coeffi ci ents ar e i n ascendi ng power of 1/z.
Dialog Box
Characteristics No. of I nputs/Output 1/1
Vector i zed I nputs Real /Compl ex
Vector i zed Outputs Compl ex
Ti me Base Di scr ete
States 2*(l ength(numerator )+
l ength(denomi nator )-2)
Di r ect feedthrough Yes, i f the 1st el ement i n numerator i s
non-zer o.
Speci fy the numer ator and denomi nator
coeffi ci ents of the compl ex fi l ter. The coeffi ci ents
must be i n ascendi ng power s of 1/z. When the
denomi nator i s set to 1, the fi l ter i s an FI R fi l ter.
Speci fy the cal cul ati on sampl e ti me i n seconds
6-261
6
Channels
A channel i s a communi cati on medi a that tr ansfer s a si gnal fr om the
tr ansmi tti ng si de to the r ecei vi ng si de. A channel may reduce the si gnal qual i ty
i n the recei vi ng si de because of tr ansmi tti ng noi se, transmi tti ng i nterference,
and tr ansmi tti ng l oss. Ther e ar e a l ar ge number of di ffer ent tr ansmi tti ng
channel s i n i ndustr i al appl i cati ons. Thi s subl i brary provi des model s for both
passband channel s and baseband channel s. The fi gur e bel ow shows the
Channel Subl i br ary:
Figure 6-35: Passband Channel Sublibrary
6-262
The passband channel provi des four bl ocks:
AWGN Channel
Varyi ng AWGN Channel
Bi nar y-err or channel
Li mi ted bi nary-er ror channel
Channel Reference Table
Thi s tabl e l i sts the Si mul i nk bl ocks i n the Channel Subl i brar y.
(Thi s tabl e l i sts the bl ocks i n al phabeti cal order for your conveni ence.):l
Block Name Description
AWGN Channel Addi ti ve Whi te Gaussi an noi se, the most
common passband channel model
Bi nary Er ror Channel Bi nar y noi se wi th bi nary si gnal i nput and
bi nary si gnal outputs
Li mi ted Bi nar y Err or
Channel
Bi nar y noi se wi th l i mi ted er ror occurance
probabi l i ty
Rayl ei gh Fadi ng CE
Channel
Rayl ei gh noi se, model ed i n baseband, wi th
si gnal attenuati on
Rayl ei gh Noi se CE Channel Rayl ei gh noi se model ed i n baseband
Ri ci an Noi se CE Channel Ri ci an noi se model ed i n baseband
Var yi ng AWGN Channel Addi ti ve Whi te Gaussi an noi se, model ed i n
passband, wi th varyi ng stati sti cal parameters
Var yi ng Rayl ei gh Fadi ng CE
Channel
Rayl ei gh noi se, model ed i n baseband, wi th
var yi ng stati sti cal parameter s and si gnal
attenuati on
Var yi ng Rayl ei gh Noi se CE
Channel
Rayl ei gh noi se, model ed i n baseband, wi th
var yi ng stati sti cal parameter s
Var yi ng Ri ci an Noi se CE
Channel
Ri ci an noi se, model ed i n baseband, wi th
var yi ng stati sti cal parameter s
AWGN Channel
6-263
6
AWGN Chann el
Catagory Passband Channel
Location Channel Subl i br ary
Description The AWGN (addi ti ve whi te Gaussi an noi se) Channel bl ock adds whi te
Gaussi an noi se to the si gnal transmi tti ng through thi s channel . The AWGN
channel model i s commonl y used i n communi cati ons. The model for an AWGN
channel i s:
Thi s bl ock uses the Gaussi an Whi te Noi se Generator bl ock as the noi se source.
The vector l ength for the entr y i n the Initial Seed parameter must match the
i nput vector si ze of thi s bl ock. The output vector si ze equal s the i nput vector
si ze.
You must speci fy the mean(s) and covar i ances of the of the noi se. The mean can
be ei ther a vector of l ength equal to the seed or a scal ar, i n whi ch case al l the
el ements of the noi se vector share the same mean val ue. The covari ance matr i x
can be one of three thi ngs:
An N-by-N posi ti ve semi -defi ni te matri x, where N i s the l ength of the seed.
The off-di agonal el ements of the matr i x are the cor rel ati ons.
A l ength N vector, i n whi ch case the i ndi vi dual el ements of the noi se vector
are uncorr el ated but have unequal vari ances.
A scal ar , i n whi ch case al l the el ements of the noi se vector are uncorr el ated
but share the same var i ance.
Noise
source
+
s(t)
s(t) + n(t)
n(t)
AWGN Channel
AWGN Channel
6-264
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs Yes/Yes
Ti me Base Auto
States N/A
Di r ect feedthrough Yes
Speci fy the mean and var i ance of the noi se
output.
I ni ti al i ze the seed. The l ength of the seed sets the
l ength of the r andom output vector .
Varying AWGN Channel
6-265
Varyi ng
AWGN Chan nel
Catagory Passband Channel
Location Channel Subl i br ary
Description The AWGN (addi ti ve whi te Gaussi an noi se) Channel bl ock adds whi te
Gaussi an noi se to the si gnal transmi tti ng through thi s channel . The AWGN
channel model i s commonl y used i n communi cati on.
Thi s bl ock has thr ee i nput por ts and one output port. The fi r st i nput por t
i nputs the transmi tti ng si gnal . The second i nput por t i nputs the mean val ue of
the Gaussi an noi se. The thi rd i nput por t i nputs the var i ance. The second and
the thi rd i nput por t can accept a scal ar or a vector si gnal . I n the vector case,
the vector l ength must equal the l ength of the fi rst i nput por t si gnal . The vector
l ength for the entr y i n the Initial Seed par ameter must match the i nput vector
si ze of thi s bl ock. The output vector si ze equal s the i nput vector si ze.
Dialog Box
Characteristics No. of I nputs 3/1
Vector i zed I nputs/Outputs Yes/Yes
Ti me Base Auto
States N/A
Di r ect feedthr ough Yes
I ni ti al i ze the seed.
Binary Error Channel
6-266
Bi nary Err or Channel
Category Passband Channel
Location Channel Subl i br ary
Description The Bi nar y Err or Channel bl ock generates adds bi nar y er ror s to the si gnal
transmi tted through thi s channel . Thi s bl ock i s useful for the bi nary si gnal
transmi ssi on.
Thi s bl ock has one i nput por t and two output ports. The i nput por t takes the
transmi tti ng bi nar y si gnal . The fi rst output port outputs the bi nary si gnal
passed the channel . The second output port outputs the number of er rors added
to the transmi tti ng si gnal .
To use thi s bl ock, you must speci fy the er ror occur ri ng probabi l i ty and the
i nput si gnal vector si ze.
The par ameter speci fi ed i n the fi r st parameter entree i s the bi nar y err or
occurr i ng pr obabi l i ty. I f you need to speci fy the er ror patter n, you shoul d use
the Li mi ted Bi nar y Err or Channel .
Dialog Box
Characteristics No. of I nputs/Outputs 1/2
Vector i zed I nputs/Outputs Yes/Yes
Ti me Base Auto
States N/A
Di r ect feedthrough Yes
The bi nar y er r or occur r i ng probabi l i ty. The val ue
of thi s par ameter must be no smal l er than zer o
and no l ar ger than one.
I nput si gnal vector l ength, whi ch i s the same
vector l ength of the si gnal to the fi r st output por t.
Limited Binary Error Channel
6-267
Li mi ted Bi nary Error Chann el
Category Passband Channel
Location Channel Subl i br ary
Description The Li mi ted Bi nary Er ror Channel bl ock generates adds bi nary er rors to the
vector si gnal tr ansmi tted thr ough thi s channel . Thi s bl ock i s useful for bi nar y
si gnal tr ansmi ssi on.
Thi s bl ock has one i nput por t and two output por ts. The i nput por t takes the
tr ansmi tti ng bi nar y si gnal . The fi r st output port outputs the bi nary si gnal
passed the channel . The second output port outputs the number of er ror s added
to the transmi tti ng si gnal at the cur rent computati on.
To use thi s bl ock, you must speci fy the i nput si gnal vector l ength, the er ror
occur ri ng pattern, and the r andom number generator seed.
You can speci fy the err or occur i ng patter n for thi s bl ock as a vector, [p1, p2,
p3,...pM], wher e p1 i s the probabi l i ty of a si ngl e er ror i n the channel for the
curr ent computi ng output vector, p2 i s the probabi l i ty of two er rors, p3 i s the
probabi l i ty of three error s, and so on. The vector si ze M must be l ess than or
equal to the bl ock output l ength. Pl ease note that . The pr obabi l i ty
of al l zero vectors i s . The mi ni mum vector si ze for thi s pr obabi l i ty
vector i s 1 and the maxi mum vector si ze for thi s vector i s the i nput si gnal
vector l ength.
Dialog Box
p
i
i 1 =
m

1
1 p
i
i 1 =
m

I nput si gnal vector l ength, whi ch i s al so the


vector l ength of the fi r st output port.
Speci fy the er r or occur patter n. The sum of thi s
vector must be no l ar ger than 1. The vector
l ength of thi s entr y shoul d be no l ar ger than the
i nput vector l ength.
I ni ti al i ze the seed.
Limited Binary Error Channel
6-268
Characteristics No. of I nputs/Outputs 1/2
Vector i zed I nputs/Outputs Yes/Yes
Ti me Base Auto
States N/A
Di r ect feedthrough Yes
Rayleigh Fading CE Channel
6-269
Rayl ei gh Fadi ng CE
Ch annel
Catagory Baseband Channel
Location Channel Subl i br ary
Description The Rayl ei gh Fadi ng CE Channel bl ock al ters the ampl i tude and phase of the
baseband si gnal transmi tti ng through thi s channel . The i nput and the output
of the bl ock are scal ar compl ex si gnal s. The Rayl ei gh fadi ng channel assumes
al l frequency components of the transmi tted si gnal undergo the same
attenuati on and phase shi ft. The r el ati on between the i nput si gnal u(t) and the
output si gnal y(t) of thi s bl ock has the rel ati onshi p
where i s the fadi ng envel ope and i s the phase shi ft of the channel . Thi s
bl ock requi res you to assi gn both fadi ng envel ope and phase shi ft i n the
parameter s entr i es.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs Compl ex/Compl ex
Ti me Base Auto
States N/A
y t ( ) e
j
u t ( ) =
Speci fy the fadi ng envel ope, a scal ar . Thi s
parameter i s i n the Rayl ei gh fadi ng channel
equati on.
Speci fy the phase shi ft, a scal ar . Thi s parameter
i s i n the Rayl ei gh fadi ng channel equati on.
Varying Rayleigh Fading CE Channel
6-270
Varyi ng Rayl ei gh
Fadi n g CE Chan nel
Catagory Baseband Channel
Location Channel Subl i br ary
Description The Rayl ei gh Fadi ng CE Channel bl ock changes the ampl i tude and phase of
the baseband si gnal transmi tti ng through thi s channel . The Rayl ei gh fadi ng
channel assumes al l frequency components of the transmi tted si gnal undergo
the same attenuati on and phase shi ft. The r el ati on between the i nput si gnal
u(t) and the output si gnal y(t) of thi s bl ock has the rel ati onshi p
wher e (t) i s the fadi ng envel ope and (t) i s the channel phase shi ft. These two
parameter s are scal ar factors i nputted fr om second and thi r d i nput ports
respecti vel y.
The fi rst ports i nput and the output are scal ar compl ex si gnal s. The second and
thi r d i nputs are r eal numbers. There are no par ameters to set i n thi s bl ock.
Dialog Box
Characteristics No. of I nputs/Outputs 3/1
Vector i zed I nput 1 Compl ex
Vector i zed I nputs 2 and 3 No, No
Vector i zed Outputs Compl ex
Ti me Base Auto
States N/A
Di r ect feedthrough Yes
y t ( ) t ( )e
j t ( )
u t ( ) =
Rayleigh Noise CE Channel
6-271
Rayl ei gh Noi se CE
Ch annel
Catagory Baseband Channel
Location Channel Subl i br ary
Description The Rayl ei gh Noi se CE Channel bl ock adds two uncorrel ated Gaussi an noi ses
to the real and i magi nar y parts of the baseband si gnal tr ansmi tti ng thr ough
thi s channel . The i nput and output are scal ar compl ex si gnal s. The Rayl ei gh
noi se channel i s wi del y used i n baseband channel si mul ati ons.
Thi s bl ock uses the Gaussi an Random Noi se Gener ator bl ock. The mean val ue
i s zero. The covari ance matr i x i s diag(
2
,
2
), where
2
i s the entr y to the
parameter sigma.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs Compl ex/Compl ex
Ti me Base Auto
States N/A
Di r ect feedthr ough Yes
Speci fy the var i ance
2
for the noi se.
Thi s par ameter i s a scal ar .
I ni ti al i ze the seed, a l ength two vector .
Varying Rayleigh Noise CE Channel
6-272
Varyi ng Rayl ei gh
Noi se CE Chann el
Catagory Baseband Channel
Location Channel Subl i br ary
Description The Varyi ng Rayl ei gh Noi se CE Channel bl ock adds two uncor rel ated
Gaussi an noi ses to the real and i magi nar y parts of the baseband si gnal
transmi tti ng thr ough thi s channel . The Rayl ei gh noi se channel i s a wi del y used
addi ti ve noi se i n baseband channel si mul ati ons.
Thi s bl ock uses the Gaussi an Random Noi se Gener ator bl ock as the noi se
sour ce. The mean val ue i s zer o. The covar i ance matri x i s diag(
2
(t),
2
(t)),
wher e
2
(t) i s the val ue i nputted to the second i nput por t of thi s bl ock.
The fi r st i nput por t i nputs the compl ex tr ansmi tti ng si gnal . The second i nput
por t i nputs the var i ance of the Gaussi an noi se. The i nput val ue must be a
non-negati ve scal ar val ue.
Dialog Box
Characteristics No. of I nputs/Outputs 2/1
Vector i zed I nput 1 Compl ex
Vector i zed I nput 2 No
Ti me Base Auto
States N/A
Di r ect feedthrough Yes
I ni ti al i ze the seed, a l ength two vector .
Rician Noise CE Channel
6-273
Ri ci an Noi se CE
Ch annel
Catagory Baseband Channel
Location Channel Subl i br ary
Description The Ri ci an Noi se CE Channel bl ock adds two uncorr el ated nonzero mean
Gaussi an noi ses to the real and i magi nar y parts of the baseband si gnal
tr ansmi tti ng thr ough thi s channel . The i nput and the output ar e scal ar
compl ex si gnal s. The Ri ci an noi se channel model i s a general i zed addi ti ve noi se
i n baseband channel si mul ati ons.
Thi s bl ock uses the Gaussi an Random Noi se Gener ator bl ock as the noi se
sour ce. The mean val ues of the Gaussi ans used to gener ate the Ri ci an noi se ar e
[inphase_m, quadrature_m]. The covar i ance matri x i s diag(
2
,
2
), wher e the
var i ance
2
i s the entr y to the par ameter sigma. The bl ock adds the two
uncor rel ated Gaussi an noi se si gnal s to the real and i magi nar y parts of the
compl ex si gnal tr ansmi tti ng thr ough thi s channel .
Ri ci an noi se i s a noncentered
2
di stri buti on noi se. A Rayl ei gh noi se channel i s
a zer o mean Ri ci an noi se channel .
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs Compl ex/Compl ex
Ti me Base Auto
States N/A
Di r ect feedthr ough Yes
Speci fy the i n_phase and quadr atur e means of
the Gaussi an noi se.
Speci fy the var i ance of the Gaussi an noi se.
I ni ti al i ze the seed, a l ength two vector .
Varying Rician Noise CE Channel
6-274
Varyi ng Ri ci an
Noi se CE Chann el
Catagory Baseband Channel
Location Channel Subl i br ary
Description The Varyi ng Ri ci an Noi se CE Channel bl ock adds two uncor rel ated nonzer o
mean Gaussi an noi ses to the real and i magi nar y parts of the baseband si gnal
transmi tti ng through thi s channel . The Ri ci an noi se channel model i s a
gener al i zed addi ti ve noi se i n baseband channel si mul ati ons. Thi s bl ock uses a
l ength two Gaussi an noi se vector as the noi se sour ce
Thi s bl ock has three i nput por ts. The fi r st por t i nputs the compl ex transmi tti ng
si gnal . The second i nput port i nputs the mean val ue m, wher e m i s a scal ar.
The mean val ue vector i s [m, m]. The thi rd i nput port i nputs the covar i ance c,
wher e c i s al so a scal ar . The covar i ance matri x i s diag(c, c). The two
uncorr el ated Gaussi an noi se si gnal s are added to the real and i magi nar y
components of the compl ex si gnal tr ansmi tti ng thr ough thi s channel .
Ri ci an noi se i s a noncentered
2
di stri buti on noi se. A Rayl ei gh noi se channel i s
a zer o mean Ri ci an noi se channel .
Dialog Box
Characteristics No. of I nputs/Outputs 3/1
Vector i zed I nput 1 Compl ex
Vector i zed I nputs 2 and 3 No, No
Ti me Base Auto
States N/A
Di r ect feedthrough Yes
I ni ti al i ze the seed, a two-el ement vector .
6-275
6
Synchronization
A recei ver must be synchroni zed wi th the transmi tter i n order to r ecei ve a
tr ansmi tted si gnal cor rectl y. Synchr oni zati on techni ques pl ay very i mpor tant
rol es i n communi cati on systems.
The synchroni zati on techni ques i n communi cati on systems i ncl udes phase,
frequency, symbol , and frame synchroni zati on. Phase synchroni zati on
techni ques are commonl y cal l ed phase l ock techni ques. Thi s tool box
i mpl ements anal og phase l ocked-l oop (PLL) and the cl assi cal di gi tal PLL as
exampl es of usi ng Si mul i nk bl ocks to bui l d synchr oni zati on functi onal i ti es.
There are a number of PLL i mpl ementati on methods. The most commonl y used
PLL methods ar e:
Si mpl e PLL
Baseband model PLL
Li near baseband model PLL
Char ge pump PLL
Thi s fi gure shows the Synchroni zati on Subl i br ary:
Figure 6-36: Synchronization Sublibrary
6-276
Synchronization Reference Table
Thi s tabl e l i sts the Si mul i nk bl ocks i n the Synchroni zati on subl i br ar y.
(Thi s tabl e l i sts the bl ocks i n al phabeti cal or der for your conveni ence.):
Block Name Description
Baseband Model PLL I mpl ements a baseband model of
the phase-l ocked l oop
Charge Pump PLL I mpl ements a charge pump phase
l ocked l oop, whi ch uses a sequenti al
l ogi c phase detector
Li near i zed Baseband Model PLL I mpl ements a l i neari zed model of
the phase l ocked l oop
PLL I mpl ements a phase l ocked l oop,
whi ch r ecovers the phase of the
i nput si gnal
PLL
6-277
6
PLL
Catagory Phase Recover y
Location Synchroni zati on Subl i br ary
Description The PLL (phase-l ocked l oop) bl ock automati cal l y adjusts the phase of a l ocal l y
gener ated si gnal to match the phase of the i nput si gnal . Thi s bl ock i s a phase
synchroni zati on bl ock that uses a si mpl e phase l ocked l oop method. A PLL i s a
feedback contr ol system to automati cal l y adjust the phase of a l ocal l y
gener ated si gnal
to the phase of an i ncomi ng si gnal
provi ded that the frequency of the i ncomi ng si gnal f
0
i s known. The l i mi tati on
of the PLL i s that the (t) i s a sl owl y changi ng var i abl e wi th respect to the val ue
of f
0
.
A typi cal PLL consi sts of thr ee components: a phase detector , a fi l ter H(s), and
a VCO (vol tage control l ed osci l l ator). The phase detector i n a si mpl e PLL i s a
mul ti pl i er. The str ucture of a si mpl e PLL i s shown i n the fi gur e bel ow:
Figure 6-37: The Structure of a Typical Phase-Locked Loop
Note that has been added to the VCO as the i ni ti al val ue of the phase shi ft.
The output of the mul ti pl i er , x(t), equal s:
s t ( ) 2f
0
t t ( ) + ( ) si n =
s t ( ) 2f
0
t t ( ) + ( ) si n =
H(s)
VCO
s t ( )
s t ( )
x t ( ) e t ( )
Phase
Detector

2
---
x t ( )
1
2
--- t ( ) t ( ) [ ] si n
1
2
--- 2f
0
t + t ( ) t ( ) [ ] si n + =
PLL
6-278
After passi ng through a l ow-pass fi l ter H(s), the si gnal e(t) becomes: Note that
the PLL fai l s when the devi ati on of i s cl ose to .
H(s) i s a l owpass fi l ter . You can use the functi on pl l f i l t to desi gn the fi l ter .
The i nput port takes the recei ved tr ansmi tti ng si gnal . Thi s bl ock has three
output ports. Output port 1 outputs the detected phase di ffer ence e(t). Output
por t 2 outputs the detected phase er ror x(t). Output por t 3 outputs the phase
matched si gnal wi th a /2 phase del ay.
Dialog Box
Characteristics No. of I nputs/Outputs 1/3
Vector i zed I nputs/Outputs No/No
Ti me Base Auto
States N/A
Di r ect feedthrough Yes
e t ( )
1
2
--- t ( )

t ( ) [ ] si n =
t ( ) f
0
s t ( )
Speci fy the numer ator and denomi nator of the
l owpass fi l ter s transfer functi on.
The VCO osci l l ator fr equency. Match thi s val ue
to the fr equency of the i nput si gnal .
The i ni ti al phase of the VCO osci l l ator si gnal .
The ampl i tude of the VCO osci l l ator si gnal .
Sel ect a gai n for the outputted si gnal
(output por t 1).
Charge Pump PLL
6-279
Charge Pu mp
PLL
Catagory Phase Recover y
Location Synchroni zati on Subl i br ary
Description The Char ge Pump PLL (phase-l ocked l oop) bl ock i s a phase synchroni zati on
bl ock, whi ch means that i t automati cal l y adjusts the phase of a l ocal l y
gener ated si gnal to match the phase of an i nput si gnal . A typi cal PLL consi sts
of three components: a phase detector , a fi l ter H(s), and a VCO (vol tage
control l ed osci l l ator ). I n the PLL bl ock, a mul ti pl i er i s used as phase detector.
I n pr acti ce, a number of other phase detector s can be used. One of them i s the
sequenti al l ogi c phase detector. A PLL wi th a sequenti al l ogi c phase detector
(al so cal l ed a di gi tal phase detector) i s known as a charge pump PLL.
A sequenti al l ogi c phase detector oper ates on the zer o crossi ngs of the si gnal
wavefor m. The equi l i bri um poi nt of the phase di ffer ence between the i nput
si gnal and the VCO si gnal equal s . The sequenti al l ogi c detector can
compensate for any fr equency di ffer ence that mi ght exi st between a VCO and
an i ncomi ng si gnal fr equency. Hence, the sequenti al l ogi c phase detector acts
as fr equency detector. For thi s r eason, a sequenti al l ogi c phase detector i s al so
cal l ed a phase/frequency detector (PFD). A di scussi on of the charge pump PLL
can be found i n .
The i nput port i nputs the r ecei ved transmi tti ng si gnal . The fi r st outpor t
outputs the detected phase di ffer ence. The second outport outputs the phase
detector output, whi ch i s the detected er ror . The thi r d outpor t outputs the
phase matched si gnal wi th the i nput except a phase del ay.
Charge Pump PLL
6-280
Dialog Box
Characteristics No. of I nputs/Outputs 1 /3
Vector i zed I nputs/Outputs No/No
Ti me Base Auto
States N/A
Di r ect feedthrough Yes
Speci fy the numer ator and denomi nator of the
l owpass fi l ter s transfer functi on.
The VCO osci l l ator fr equency. Match thi s val ue
to the fr equency of the i nput si gnal .
The i ni ti al phase of the VCO osci l l ator si gnal .
The ampl i tude of the VCO osci l l ator si gnal .
Sel ect a gai n for the outputted si gnal
(output por t 1).
Baseband Model PLL
6-281
Baseban d Model
PLL
Catagory Phase Recover y
Location Synchroni zati on Subl i br ary
Description The Baseband Model PLL (phase-l ocked l oop) bl ock i s a phase synchroni zati on
bl ock that uses a baseband model method. A typi cal PLL consi sts of three
components: a phase detector , a fi l ter H(s), and a VCO (vol tage contr ol l ed
osci l l ator)Fi gur e 6-37:. Usi ng the mul ti pl i er phase detector and r earr angi ng
the var i abl es, the PLL i n the fi gur e bel ow i s equi val ent to the baseband model
of the PLL:
Figure 6-38: PLL Baseband Model
The baseband model for the PLL i s a nonl i near system. The model depends on
the ampl i tude A
c
of the i ncomi ng si gnal . The model i s i ndependent of the
carr i er fr equency f
0
.
The i nput of thi s bl ock i s the recei ved transmi ssi on si gnal . The output of thi s
bl ock i s the detected phase di ffer ence.
H(s) + A
c
. ( ) si n
s t ( ) t ( )
s t ( )
K
-
1
s
---
Baseband Model PLL
6-282
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Auto
States N/A
Di r ect feedthrough Yes
Speci fy the numer ator and denomi nator of the
l owpass fi l ter s transfer functi on.
The VCO frequency. Match thi s val ue to the
fr equency of the i nput si gnal .
The ampl i tude of the VCO si gnal .
Sel ect a gai n for the outputted si gnal
(output por t 1).
Linearized Baseband Model PLL
6-283
Li neari zed Baseband
Model PL L
Catagory Phase Recover y
Location Synchroni zati on Subl i br ary
Description The Li neari zed Baseband Model PLL bl ock i s an i mpl ementati on of the
si mpl est PLL model . A typi cal PLL consi sts of three components: a phase
detector , a fi l ter H(s), and a VCO (vol tage control l ed osci l l ator)Fi gure 6-37:.
The baseband model for the PLL i s a nonl i near system. I t i s di ffi cul ty to
anal yze a nonl i near system. Assumi ng that the phase er ror i s smal l , the
equati on can be used as an appr oxi mati on. Thi s approxi mati on
l eads to a l i neari zed baseband model PLL as shown i n the fi gur e bel ow:
Figure 6-39: Linearized PLL Baseband Model
The transfer functi on fr om the i nput phase to phase er ror i s
A PLL wi thout a fi l ter i s a fi rst order PLL. A PLL wi th (n- 1)th order H(s) i s a
nth or der PLL. I t i s known that the steady state phase error i s zero for a
rati onal H(s). You can use the Contr ol System Tool box to desi gn and to anal yze
the PLLs.
The model depends on the ampl i tude A
c
of the i ncomi ng si gnal . The model i s
i ndependent of the car ri er fr equency f
0
.
The i nput of thi s bl ock i s the recei ved transmi tti ng si gnal . The output of thi s
bl ock i s the detected phase di ffer ence.
t ( )
t ( ) si n t ( ) =
H(s) +
1
s
---
A
c
K
s t ( ) t ( )
s t ( )
-
s t ( ) t ( )
G s ( )
s
s A
c
KH s ( ) +
------------------------------- =
t ( )
Linearized Baseband Model PLL
6-284
Dialog Box
Characteristics No. of I nputs/Outputs 1 /1
Vector i zed I nputs/Outputs No/No
Ti me Base Auto
States N/A
Di r ect feedthrough Yes
Speci fy the numer ator and denomi nator of the
l owpass fi l ter s transfer functi on.
The VCO frequency. Match thi s val ue to the
fr equency of the i nput si gnal .
The ampl i tude of the VCO si gnal .
Sel ect a gai n for the outputted si gnal
(output por t 1).
6-285
6
Utilities
Thi s tool box i ncl udes a number of useful bl ocks i n communi cati on system
desi gn and anal ysi s that do not fi t any of the categor i es menti oned i n the
previ ous secti ons. Many of these bl ocks are used as the basi c bl ocks to bui l d
other functi on bl ocks.
6-286
Thi s fi gure shows the Uti l i ty Subl i br ary:
Figure 6-40: Utility Sublibrary
6-287
Utility Reference Table
Thi s tabl e l i sts the Si mul i nk bl ocks i n the Uti l i ty Subl i brar y.
(Bl ocks are l i sted i n al phabeti cal or der for your conveni ence.)
Block Name Description
Arr ay Functi on Perfor ms a speci fi ed functi on on
each i ndex of an i nput arr ay.
Compl ex Fi l ter I mpl ements I I R and FI R compl ex
fi l ter s.
Di scr ete-Ti me Modul o I ntegr ator Di scr ete-ti me i ntegr ator usi ng a
modul o reset.
Di scr ete Ti me VCO I mpl ements a di screte-ti me vol tage
control l ed osci l l ator.
Edge Detector Detects the ri si ng edge of a si gnal .
Envel ope Detector Detects the upper or l ower bound
envel ope of the i nput si gnal .
Err or Counter Counts the number of err ors
(di ffer ences) between two i nput
si gnal s when tr i gger ed.
K-Step Del ay I ntroduces a speci fi ed number of
ti me step del ays to the i nput si gnal .
Mean and Std Cal cul ates the mean and standard
devi ati on of i nput data.
Mean and Vari ance Cal cul ates the mean and var i ance of
i nput data.
Mi n/Max I ndex Detects the mi ni mum or maxi mum
el ement of a vector and outputs the
el ements i ndex.
Modul o Perfor ms modul o ar i thmeti c.
Modul o I ntegrator I ntegrates usi ng a modul o reset.
6-288
Number Counter Counts the number of i nput pul ses.
Regi ster Shi ft Accumul ates i nput scal ars and
outputs the data i n a speci fi ed
vector for mat.
Scal ar to Vector Conver ter Coverts scal ars to a vector format.
Schedul ed Reset I ntegrator I ntegrates wi th state r eset at
speci fi ed ti me steps.
Tri ggered Buffer Down Conver ts an i nput vector i nto
sequenti al format when tri gger ed.
VCO I mpl ements a vol tage contr ol l ed
osci l l ator.
Vector Redi str i butor Redi str i butes el ements fr om i nput
vector s to output vectors i n a
speci fi ed rear rangement scheme.
Note: Thi s bl ock i s documented i n
the Mul ti pl e Access Subl i brary
secti on of thi s chapter.
Vector to Scal ar Conver ter Conver ts vectors to a scal ar for mat.
Wi ndowed I ntegrator I ntegrates wi th a fi xed i ntegr ati on
ti me wi ndow.
Block Name Description
Discrete Time Modulo Integrator
6-289
6
Di screte Ti me
Modul o I ntegr ator
Catagory Di scr ete Reset I ntegrator
Location Uti l i ty Subl i brar y
Description The Di screte Ti me Modul o I ntegrator bl ock r esets i ts i ntegr ati on state to a
modul o val ue when the state val ue exceeds the modul o bound. The bl ock
output i s r e m( i nt _out , modul e _bound) , wher e i nt _out i s the output of the
di screte-ti me i ntegrator pri or to the modul o operati on and modul o_bound i s the
output l i mi t.
The di scr ete-ti me modul o i ntegr ator keeps the output and the i ntegr ati on state
i n a fi xed r ange. The modul o i ntegr ator i s useful for monotoni cal l y i ncreasi ng
or decreasi ng functi ons, but wor ks wi th any i ntegr abl e functi on.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States 1
Di r ect feedthr ough No
Set the bound for the state modul o cal cul ati on.
I ni ti al i ze the state.
Speci fy the i ntegr ati on sampl e ti me.
Modulo Integrator
6-290
Modul o I ntegrator
Catagory Reset I ntegr ator
Location Uti l i ty Subl i brar y
Description The Modul o I ntegr ator bl ock resets i ts i ntegr ati on state to be modul o val ue
when the state val ue exceeds the modul o bound. The bl ock output i s
r e m( i nt _out , modul o_bound) , where i nt _out i s the output of the i ntegrator
pri or to the modul o oper ati on and modul o_bound i s the output l i mi t.
The modul o i ntegr ator keeps the output and the i ntegrati on state i n a fi xed
range. The modul o i ntegr ator i s useful for monotoni cal l y i ncr easi ng or
decreasi ng functi ons, but wor ks wi th any i ntegr abl e functi on.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nput/Outputs No/No
Ti me Base Conti nuous
States 1
Di r ect feedthrough No
Set the bound for the state modul o cal cul ati on.
I ni ti al i ze the state.
K-Step Delay
6-291
K-Step
Del ay
Catagory Si gnal Del ay
Location Uti l i ty Subl i brar y
Description The K-Step Del ay bl ock del ays i ts i nput si gnal by a K-sampl i ng ti me i nter val .
Thi s bl ock i nputs and outputs scal ar si gnal s, and i t i s equi val ent to a z
-k

di screte-ti me oper ator.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States K
Di r ect feedthr ough Yes
Speci fy the number of ti mesteps i n the del ay. K
must be a posi ti ve i nteger .
The ti me i nterval between sampl e, a two-el ement
vector . The fi r st el ement i s the sampl e ti me; the
second el ement, i f pr esent, i s the offset ti me fr om
the begi nni ng of the sampl e peri od.
A scal ar , whi ch speci fi es the i ni ti al condi ti on
befor e the offset ti me. The i ni ti al condi ti ons of the
K di scr ete-ti me states ar e al ways zer o.
Windowed Integrator
6-292
Wi ndowed
I ntegrator
Catagory I ntegrati on over a fi ni te ti me wi ndow
Location Uti l i ty Subl i brar y
Description The Wi ndowed I ntegrator bl ock i ntegrates the i nput si gnal usi ng a fi xed
i ntegrati on ti me wi ndow. The output y(t) of the bl ock i s:
wher e T i s a fi xed ti me wi ndow for the i ntegrati on. Thi s bl ock assumes
x(t) = 0 when t <0. The i nput si gnal can be a vector. You must speci fy the i nput
si gnal vector l ength i n the parameter assi gnment. The output vector l ength
equal s the i nput vector l ength.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs Yes/Yes
Ti me Base Di scr ete ti me
States 1
Di r ect feedthrough No
y t ( ) x ( ) d
t T
t

=
Speci fy the i nput vector l ength.
Speci fy the l ength of ti me for whi ch the i ntegr a-
ti on occurs. Thi s parameter i s T i n the wi ndowed
i ntegr ator equati on above.
Speci fy the cal cul ati on sampl e ti me. Thi s
par ameter must be l ess than T.
A str i ng vari abl e. Sel ect the i ntegr ati on method.
Scheduled Reset Integrator
6-293
Schedul ed Reset I n tegr ator
Catagory I ntegrati on wi th r eset
Location Uti l i ty Subl i brar y
Description The Schedul ed Reset I ntegrator bl ock r esets i ts states fol l owi ng a fi xed
resetti ng schedul e. The output of thi s bl ock y(t) i s
where ts i s the l ast state reset ti me. The state r eset ts = k ti me_i nterval +
offset, where k i s an i nteger . The above i ntegr ati on formul a appl i es for the
enti r e ti me i nterval .
The bl ock combi nes the functi onal i ty of the Reset I ntegr ator and Modul o
I ntegrator bl ocks. The bl ock cal cul ates i ts i ntegrati on state wi th a modul e
bound. The output val ue of thi s bl ock i s equi val ent to r em( y ( t ) ,
modul e_bound) , where y( t ) i s the output of the i ntegr ator shown i n the above
equati on.
Thi s bl ock can accept a vector i nput. The output vector si ze equal s the i nput
vector si ze.
Dialog Box
y t ( ) x ( ) d
ts
t

=
Speci fy the reset ti me. Setti ng thi s parameter to
I nf for ces the bl ock to act l i ke a nor mal di scr ete
ti me i ntegr ator . When thi s par ameter i s a
two-el ement vector , the second el ement i s the
offset val ue.
Speci fy the cal cul ati on sampl e ti me.
Set the bound for the state modul e cal cul ati on.
Scheduled Reset Integrator
6-294
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs Yes/Yes
Ti me Base Di scr ete ti me
States Number of i nputs
Di r ect feedthrough No
Register Shift
6-295
Regi ster Shi ft
Catagory I /O Uti l i ty
Location Uti l i ty Subl i brar y
Description The Regi ster Shi ft bl ock i s an I /O uti l i ty that pl aces i nput data i n an i nternal
regi ster and outputs the data fol l owi ng when a tri gger si gnal occurs. Thi s bl ock
accumul ates the scal ar i nput si gnal i n an i nter nal regi ster at every r ai si ng
edge of the tr i gger ed si gnal . The output of thi s bl ock can be a vector or scal ar.
The i ni ti al condi ti ons of al l r egi ster s ar e assi gned zer os. When the bl ock detects
a tri gger, the content i n i th i ndex of the r egi ster shi fts to (i +1)th i ndex. The
0th i ndex keeps the curr ent i nput val ue. The output fol l ows a FI FO (fi r st i n,
fi rst out) pattern. The number of i ndi ces output when a tr i gger occur s i s equal
to the number of del ay steps speci fi ed i n par ameter Delay steps. Setti ng Delay
steps to 1 means that a scal ar val ue wi l l be output when a tri gger occur s.
Setti ng Delay steps to a val ue n>1 means that a l ength n vector wi l l be output
when a tri gger occurs.
The bl ock detects a tri gger when the tri gger si gnal crosses from bel ow the
threshol d val ue to above or equal to the thr eshol d val ue.
I nput port 1 takes the i nput si gnal val ue, and i nput port 2 takes the tri gger si gnal .
Dialog Box
Speci fy how many del ay steps the bl ock uses.
Set the thr eshol d val ue for the tr i gger si gnal .
Register Shift
6-296
Characteristics No. of I nputs/Outputs 1/2
Vector i zed I nputs/Outputs No/Yes
Ti me Base Auto
States The maxi mum number i n the output vector
patter n pl us one.
Di r ect feedthrough Yes, when the mi ni mum number i n the
output vector patter n i s zero; otherwi se, no.
Triggered Buffer Down
6-297
Tr i gger ed Buffer Down
Catagory I /O Uti l i ty
Location Uti l i ty Subl i brar y
Description The Tr i gger ed Buffer Down bl ock converts a vector si gnal i nto sequenti al
si gnal (s). The bl ock has thr ee i nput por ts. I nput port 1 takes a vector si gnal ,
i nput por t takes the i nput-tri gger si gnal , and i nput port 3 takes the
output-tri gger si gnal .
Each ti me the bl ock detects an i nput-tri gger si gnal , the bl ock repl aces i ts
i nter nal regi ster by the si gnal i nput fr om the fi rst i nput port. I nsi de the bl ock,
ther e i s an i ndex counter, whi ch keeps the r egi ster i ndex number fr om where
the bl ock outputs i ts val ue. The bl ock outputs the i th regi ster content when the
i ndex counter val ue i s i . Each ti me the bl ock detects an output-tr i gger si gnal ,
the i ndex counter i ncreases i ts val ue speci fi ed i n the Increment for each
index parameter . The i ni ti al val ues i n the regi sters are zeros. The i ni ti al val ue
for the i ndex counter can be set by the val ue i n the Initial index parameter .
Each ti me an i nput-tr i gger si gnal i s detected, the i ndex counter i s reset to the
i ni ti al i ndex val ue.
Thi s bl ock outputs a vector when the val ue i n the i ncrement for each i ndex i s
a vector. The output vector si ze i s the same as the vector si ze i n the entr y. Each
output keeps i ts own i ndex counter and the i ncrement val ues ar e added
i ndependentl y. The i ncr ement val ue must be an i nteger, but i t can be a
negati ve i nteger.
The bl ock detects the rai si ng edge of a tri gger when the tr i gger si gnal crosses
the thr eshol d val ue fr om bel ow. The si gnal does not have to actual l y cr oss the
threshol d; a tri gger occur s even i f the si gnal remai ns constant at the thr eshol d
val ue as l ong as i t approached the threshol d val ue from bel ow.
The fi r st output por t outputs the sequenti al si gnal (s). The second output port
outputs a spi ke when the i nter nal regi ster s are r efreshed.
Example Let the bl ock i nput be a l ength 3 vector. The I ni ti al i ndex i s a two-el ement zer o
vector. The i ncrement for each i ndex i s [1, 2]. The output tri gger si gnal
frequency i s three ti mes the i nput-tri gger si gnal fr equency. The cycl i c si gnal
fl ag i s 1.
Triggered Buffer Down
6-298
As shown i n the fi gure bel ow, at t0, the contents i n the regi sters refresh to [0,
2, 1]. The fi rst output si gnal s at t0, t1, t2 ar e 0, 2, 1 respecti vel y. The second
output si gnal s at t0, t1, t2 are 0, 1, 2 respecti vel y.
Figure 6-41: Example for Triggered Buffer Down Block
signal 1
signal 2
signal 3
input_trigger output_trigger
Triggered
Buffer
Down
output 1
output 2
t1 t0 t2 t3 t4 t5 t7 t6 t0
t3 t6
Triggered Buffer Down
6-299
Dialog Box
Characteristics No. of I nputs/Outputs 3/2
Vector i zed I nput 1 Yes
Vector i zed I nput 2 and 3 No, No
Vector i zed Output 1 Yes
Vector i zed Output 2 No
Ti me Base Auto
States The i nput vector si ze
Di r ect feedthr ough Yes
Speci fy the i nput vector l ength.
Set the i ni ti al val ue for the i ndex counter . Thi s
parameter al so sets the output vector l ength.
The i ncr ement val ue for each i ndex. The l ength of
thi s vector must equal the l ength of the i ni ti al
i ndex vector.
Set the thr eshol d for the tr i gger si gnal .
When the i ndex exceeds the r egi ster si ze, ther e
ar e two opti ons. The fi r st opti on i s cycl i c, whi ch
forces the bl ock to r ecal cul ate the bl ock usi ng
modul o N ar i thmeti c, where N i s the i nput si gnal
vector si ze. The second opti on i s just to for ce the
output to 0.
Discrete Time VCO
6-300
Di screte Ti me
VCO
Catagory Uti l i ty
Location Uti l i ty Subl i brar y
Description The Di scr ete Ti me VCO (vol tage control l ed osci l l ator) bl ock gener ates a si gnal
wi th fr equency proporti onal to the vol tage of the i nput si gnal . Thi s i s a
di screte-ti me bl ock.
For a gi ven i nput si gnal u(t), the VCO outputs y(t):
wher e k
c
i s the sensi ti vi ty constant of the VCO and i s the i ni ti al phase shi ft.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Di scr ete ti me
States N/A
Di r ect feedthrough Yes
y t ( ) A
c
2f
c
t 2k
c
u t ( )dt
0
t

+ +
,
_
cos =
Speci fy the output ampl i tude, whi ch i s vari abl e
A
c
i n the VCO equati on above.
The modul ati on fr equency, whi ch i s var i abl e f
c
i n
the VCO equati on.
The phase sensi ti vi ty val ue, whi ch i s the gai n
appl i ed to the i nput si gnal .
The i ni ti al phase of the osci l l ator .
The cal cul ati on sampl e ti me.
VCO
6-301
VCO
Catagory Vol tage Control l ed Osci l l ati on
Location Uti l i ty Subl i brar y
Description The VCO (vol tage control l ed osci l l ator) bl ock gener ates a si gnal that i s
proporti onal to the vol tage of the i nput si gnal .
For a gi ven i nput si gnal u(t), the VCO outputs y(t):
where k
c
i s the sensi ti vi ty constant of the VCO and i s the i ni ti al phase shi ft.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Conti nuous
States N/A
Di r ect feedthr ough Yes
y t ( ) A
c
2f
c
t 2k
c
u t ( )dt
0
t

+ +
,
_
cos =
Speci fy the output ampl i tude, whi ch i s var i abl e
A
c
i n the VCO equati on above.
The modul ati on fr equency, whi ch i s var i abl e f
c
i n
the VCO equati on.
The phase sensi ti vi ty val ue, whi ch i s the gai n
appl i ed to the i nput si gnal .
The i ni ti al phase of the osci l l ator.
Envelope Detector
6-302
En vel ope Detector
Catagory Uti l i ty
Location Uti l i ty Subl i brar y
Description The Envel ope Detector bl ock detect the upper or l ower boundar y envel ope. You
can use thi s bl ock to outl i ne the envel ope of a gi ven si gnal or i n si gnal
demodul ati on. The bl ock detects the l ocal maxi mum (when the upper envel ope
i s found) or the l ocal mi ni mum (when the l ower envel ope i s found). Because of
the detecti on method used, the resul t of the Envel op Detector i s noi se sensi ti ve.
For the best sol uti on, use a l owpass fi l ter befor e the envel ope detector .
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Auto
States N/A
Di r ect feedthrough Yes
A str i ng vari abl e. Speci fy whether the bl ock
detects the upper or l ower boundar y.
Edge Detector
6-303
Edge Detector
Catagory Rai si ng Edge Detecti on
Location Uti l i ty Subl i brar y
Description The Edge Detector bl ock detects the r ai si ng edge of a si gnal . Thi s bl ock scans
through the i nput si gnal and fi nds the ti me when the si gnal crosses fr om bel ow
the speci fi ed thr eshol d val ue. Thi s bl ock outputs one when the r ai si ng edge i s
detected; other wi se i t outputs zeros.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/No
Ti me Base Auto
States N/A
Di r ect feedthr ough Yes
Set the thr eshol d val ue for si gnal detecti on.
Number Counter
6-304
Number Counter
Catagory Counter
Location Uti l i ty Subl i brar y
Description The Number Counter bl ock counts the number of i nput pul ses.
The fi rst i nput por t i nputs the counti ng enabl e/di sabl e si gnal , the second i nput
por t i nputs the cl ock pul se si gnal , and the thi r d i nput por t i nputs the counter
reset si gnal .
At the ti me when the cl ock pul se si gnal (second i nput port) cr osses fr om bel ow
the thr eshol d val ue t, the counter adds one i f the enabl e/di sabl e si gnal (fi rst
por t) i s l ar ger than or equal to the threshol d. The cl ock pul se si gnal i s i gnored
i f the enabl e/di sabl e si gnal i s l ess than the thr eshol d.
The counter has zero i ni ti al val ue. When the reset si gnal (thi rd port) val ue
cr osses the thr eshol d val ue fr om bel ow, the counter i s reset to zer o. The output
of thi s bl ock i s the val ue i n the counter .
Dialog Box
Characteristics No. of I nputs/Outputs 3/1
Vector i zed I nputs/Outputs No/No
Ti me Base Auto
States N/A
Di r ect feedthrough Yes
Set the thr eshol d for pul se si gnal counti ng.
Error Counter
6-305
Er ror Counter
Catagory Uti l i ty
Location Uti l i ty Subl i brar y
Description The Err or Counter bl ock counts the number di fferences between the fi rst i nput
si gnal and the second si gnal at the ti me of the r ai si ng edge of the thi rd si gnal .
When the di fference between the si gnal fr om the fi r st and second ports i s l arger
than a tol er ance val ue, the er ror counter adds one. The r ai si ng edge of the
four th si gnal resets the er ror counter . Thi s bl ock accepts scal ar si gnal s onl y.
Dialog Box
Characteristics No. of I nputs/Outputs 4/1
Vector i zed I nputs/Outputs No/No
Ti me Base Auto
States N/A
Di r ect feedthr ough Yes
Set the threshol d val ue for the r i si ng edge of the
thi r d i nput si gnal .
Speci fy the tol er ance al l owed between the fi rst
and second i nput si gnal s.
Min/ Max Index
6-306
Mi n/Max
I ndex
Catagory Uti l i ty
Location Uti l i ty Subl i brar y
Description The Mi n/Max I ndex bl ock detects the maxi mum (or mi ni mum) el ement of the
vector i nput si gnal . I t outputs (i ndex -1) of the maxi mum (or mi ni mum)
el ement, wher e i ndex i s the i ndex of the detected el ement i n the i nput vector.
I n other wor ds, i f the i th el ement i n the i nput vector has maxi mum val ue (or
mi ni mum val ue) i n the i nput vector, the output of thi s bl ock i s i - 1. When mor e
than one el ement share the same maxi mum val ue (or mi ni mum val ue), thi s
bl ock outputs the smal l est detected i nde x -1.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs Yes/No
Ti me Base Auto
States N/A
Di r ect feedthrough Yes
A str i ng vari abl e. Sel ect whether the bl ock
detects the maxi mum or mi ni mum vector
el ement.
Array Function
6-307
Ar ray
Functi on
Catagory Mul ti pl e i nput functi ons
Location Uti l i ty Subl i brar y
Description The Arr ay Functi on bl ock outputs a functi on cal cul ati on of each el ement of the
i nput vector si gnal . The l ength of the output vector i s the same as the l ength of
the i nput vector . Each output el ement i s a functi on of the i nput el ement.
where the functi on f can be a choi ce fr om the str i ngs s i n, c os , t an, as i n, acos ,
l n, l og10, and s gn.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs Yes/Yes
Ti me Base Auto
States N/A
Di r ect feedthr ough Yes
y
i
f u
i
( ) =
A stri ng var i abl e. Speci fy whi ch functi on the
bl ock per for ms on the i nput vector .
Scalar to Vector Converter
6-308
Scal ar to Vector
Conver ter
Catagory Data Conversi on
Location Uti l i ty Subl i brar y
Description The Scal ar to Vector Conver ter bl ock conver ts a scal ar base ten posi ti ve i nteger
i nto a number wi th speci fi ed base, b. The output of thi s bl ock i s a vector wi th
gi ven output vector l ength. The fi rst el ement i n the output vector outputs the
coeffi ci ent for b
0
, the second el ement i n the output vector outputs the
coeffi ci ent for b
1
, and so on.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs No/Yes
Ti me Base Auto
States N/A
Di r ect feedthrough Yes
Pair Block Vector to Scal ar Converter
Speci fy the vector l ength of the output data.
Speci fy the base for the data conver si on. Thi s
must be an i nteger gr eater than 1.
Vector to Scalar Converter
6-309
Vector to Scal ar
Conver ter
Catagory Data Conversi on
Location Uti l i ty Subl i brar y
Description The Vector to Scal ar Conver ter bl ock converts the i nput vector i nto a scal ar
posi ti ve base ten i nteger. The i nput base i s M, whi ch i s speci fi ed i n the Input
integer base M parameter . The fi rst el ement i n the i nput vector i s the
coeffi ci ent for M
0
, the second el ement i n the i nput vector i s the coeffi ci ent for M
1
,
and so on.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs Yes/No
Ti me Base Auto
States N/A
Di r ect feedthr ough Yes
Pair Block Scal ar to Vector Converter
The base for the conver si on cal cul ati on. The
entr y must be an i nteger gr eater than 1.
Modulo
6-310
Modul o
Catagory Modul o ari thmeti c
Location Uti l i ty Subl i brar y
Description The Modul o bl ock computes the modul us i n a speci fi ed base of the i nput si gnal .
The l ength of the output vector i s the same l ength as the i nput vector . The
modul o base must be an i nteger greater than 1.
Dialog Box
Characteristics No. of I nputs/Outputs 1/1
Vector i zed I nputs/Outputs Yes/Yes
Ti me Base Auto
States N/A
Di r ect feedthrough Yes
Speci fy the base for the modul o ar i thmeti c
cal cul ati on.
Mean and Std
6-311
Mean and
Std
Catagory Stati sti cs
Location Uti l i ty Subl i brar y
Description The Mean and Std bl ock cal cul ates the runni ng mean and standard devi ati on
of the scal ar i nput. The bl ock updates the mean and standard devi ati on at a
sampl e ti me poi nt speci fi ed i n the parameter entry. The fi r st output por t
outputs the mean val ue, and the second port outputs the standard devi ati on of
the i nput si gnal .
Dialog Box
Characteristics No. of I nputs/Outputs 1/2
Vector i zed I nputs/Outputs No/No
Ti me Base Auto
States 2
Di r ect feedthr ough Yes
Speci fy the update cal cul ati on ti me of the bl ock.
Mean and Variance
6-312
Mean and
Vari ance
Catagory Stati sti cs
Location Uti l i ty Subl i brar y
Description The Mean and Var i ance bl ock cal cul ates the runni ng mean and var i ance of the
i nput scal ar si gnal . The bl ock updates i ts mean and var i ance at a sampl e ti me
poi nt gi ven i n the parameter entry. The fi r st output por t outputs the mean
val ue, and the second output port outputs the var i ant of the i nput si gnal .
Dialog Box
Characteristics No. of I nputs/Outputs 1/2
Vector i zed I nputs/Outputs No/No
Ti me Base Auto
States 2
Di r ect feedthrough Yes
Speci fy the update cal cul ati on ti me of the bl ock.

A
RTW and Communi cati ons
Template Makefiles . . . . . . . . . . . . . . . . . A-3
Example: TCM Simulation . . . . . . . . . . . . . . A-5
RTW Guidelines . . . . . . . . . . . . . . . . . . A-9
Limitations And Notes . . . . . . . . . . . . . . . A-11
A RTW and C om m unications
A-2
Thi s secti on provi des i nformati on on usi ng the Real -Ti me Workshop

(RTW)
wi th the Si mul i nk l i br ary of the Communi cati ons Tool box. I t contai ns
i nfor mati on about bui l di ng stand-al one C pr ograms fr om model s that contai n
Communi cati ons Tool box bl ocks.
See the Real-Time Workshop Users Guide for compl ete detai l s on code
generati on.
For information about... See...
Edi ti ng the templ ate makefi l e Templ ate Makefi l es on A-2
An exampl e code gener ati on task Exampl e: TCM Si mul ati on on A-4
Generati ng code fr om model s
that use MEX-fi l e S-functi ons
Wr i ti ng MEX-Fi l e S-Functi ons for
RTW on A-8
Val i d bl ock names for code
generati on
Bl ock Names and Code Gener ati on on
A-9
Limitation Li mi tati ons and Notes on A-10
Tem plate M akefiles
A-3
Template Makefiles
To generate code for your tar get pl atform, Real -Ti me Wor kshop uses a
templ ate makefi l e. A template makefile i s the model fi l e that Real -Ti me
Workshop uses to cr eate the actual makefi l e that bui l ds the executabl e code.
There i s a templ ate makefi l e for ever y suppor ted tar get and compi l er
combi nati on, al l wi th the extensi on . t mf . For exampl e:
On UNI X systems, ther e i s a standar d nonreal -ti me uni x . t mf fi l e that works
wi th Sun make or gmake and wi th cc or gcc .
On the PC, the nonreal -ti me templ ate makefi l es ar e usual l y cal l ed
dos _. t mf , wher e i s an abbr evi ati on for the compi l er . For i nstance,
dos _wat g. t mf i s the templ ate makefi l e for the WATCOM compi l er and Gnu
make faci l i ty.
Updating the Template Makefile for the Toolbox
Many of the bl ocks i n the Communi cati on Tool box Si mul i nk l i brar y are
i mpl emented as C l anguage MEX-fi l es. I f you use the Real -Ti me Workshop to
gener ate C code for a model that uses the bl ocks, you must ensur e that your
templ ate makefi l e references thei r MEX-fi l e sour ce. Modi fy your templ ate
makefi l e as fol l ows:
Add the Communi cati on Tool box c omms f un di rector y to the i ncl ude path used
by your C compi l er . For exampl e, to do thi s wi th the uni x. t mf templ ate
makefi l e, add the text shown i n bold to the MATLAB_I NCLUDES macr o
defi ni ti on.
MATLAB_I NCLUDES = \
I $( MATLAB_ROOT) /s i mul i nk/i nc l ude \
I $( CODEGEN_ROOT) /common/i ncl ude \
I $( CODEGEN_ROOT) /ex t e r nal /r pc \
I $( MATLAB_ROOT) / t ool box/ comm/ commsf un
A RTW and C om m unications
A-4
To do thi s wi th the dos _wat g. t mf fi l e, add the text shown i n bold to the
MATLAB_I NCLUDES macro defi ni ti on.
MATLAB_I NCLUDES = \
I $( CODEGEN_ROOT) \nr t \
I $( MATLAB_ROOT) \s i mul i nk\i nc l ude \
I $( MATLAB_ROOT) \s i mul i nk\s r c \
I $( CODEGEN_ROOT) \common\i ncl ude \
I $( MATLAB_ROOT) \ t ool box\ comm\ commsf un
The var i ous templ ate makefi l es use di fferent make faci l i ti es whi ch i n general
have di fferent syntaxes, so edi t your fi l e car eful l y.
Add a rul e for compi l i ng sources i n the Communi cati ons Tool box c omms f un
di rectory. Make sure that the i ndented l i nes start wi th a si ngl e tab, not
spaces.
For exampl e, to do thi s wi th the uni x. t mf templ ate makefi l e, add the text
shown i n bold to the l i st of r ul es:
%. o : $( MATLAB_ROOT) /s i mul i nk/s r c/%. c
$( CC) $( CFLAGS) c $<
%. o : $( MATLAB_ROOT) / tool box/ comm/ commsf un/ %. c
$( CC) $( CFLAGS) c $<
To do thi s wi th the dos _wat g. t mf fi l e, add the text shown i n bold to the l i st
of rul es.
%. obj : $( MATLAB_ROOT) \s i mul i nk\s r c\%. c
$( PRI NTENV) CFLAGS
$( CC) @CFLAGS $<
%. obj : $( MATLAB_ROOT) \ tool box\ comm\ commsf un\ %. c
$( PRI NTENV) CFLAGS
$( CC) @CFLAGS $<
For mor e i nfor mati on on the templ ate makefi l es provi ded wi th the Real -Ti me
Workshop, see the secti on Templ ate Makefi l es i n Chapter 3 of the Real-Time
Workshop Users Guide.
Exam ple: TC M Sim ulation
A-5
Example: TCM Simulation
Thi s secti on descr i bes how to generate C code for an exampl e model . The goal
of thi s exampl e i s to cr eate a stand-al one DOS or UNI X executabl e that reads
a si gnal from a t es t 1. dat fi l e. The contents of the fi l e i s tr ansmi tted from the
sender to the r ecei ver by usi ng the tr el l i s code modul ati on (TCM) method, the
recei ver creates a new t e s t 2. dat fi l e contai ni ng the r ecei ved data. To tr y thi s
exampl e, l oad the bl ock di agr am t s t t cm fr om the MATLAB wor kspace.
Thi s bl ock uses the convol uti on code wi th i ts transfer functi ons showi ng i n the
next fi gur e.
Rd file
Sca to vec
converter
Demux
Convl en
Vec to sca
converter
Mux
QASK
Cdemap
QADM Rayl N QAM
QASK
Cmap
k
z
Pulse
Wt file
Demux
Sca to vec
converter
Convl de
Vec to sca
converter
Mux
k
z
1
In1
1
Out1
2
Out2
XOR
A RTW and C om m unications
A-6
Cr eate a data fi l e t e s t 1. dat i n your wor ki ng space:
N = 300;
x = r andi nt ( N, 1, 4) ;
f i d = f ope n( t es t 1. dat ) ;
f or i = 1: l engt h( x )
f pr i nt f ( f i d, %d\n , x ( i ) ) ;
e nd
f cl os e( f i d) ;
To si mul ate the system, set the stop ti me to be N+3 from the par ameter of the
si mul ati on menu, wher e N i s gi ven i n the above code. Then, start the si mul ati on
from the si mul ati on menu.
The si mul ati on r esul ts i n a data fi l e t e s t 2. dat , whi ch has the same contents
(except the tr ansfer er ror ) wi th the fi l e t es t 1. dat . You can use the command
l oad t es t 1. dat to compar e the transmi tted data x and the r ecei ved data t e s t 2.
Exam ple: TC M Sim ulation
A-7
To generate code, fol l ow the procedures:
Sel ect Nonreal-Time Options fr om the Code menu.
Set the code gener ati on par ameters for your model i n the di al og box that
appear s. Note that the fi gur e bel ow shows appropri ate setti ngs for one pos-
si bl e DOS confi gurati on:
Set to N+3, where N i s the
tr ansmi tted data l ength.
Templ ate makefi l e name.
Name of makefi l e to create.
I ntegr ati on al gor i thm. Thi s
has no effect si nce the model
i ncl udes no conti nuous
bl ocks.
Bui l d command. The opti on
shoul d be defi ned when
convol uti on code/decode i s
used.
A RTW and C om m unications
A-8
Once you have set al l the parameters, cl i ck on Build.
Real -Ti me Workshop automati cal l y cr eates, compi l es, and l i nks the C code
accordi ng to the speci fi cati ons i n your templ ate makefi l e.
Run the executabl e.
From the MATLAB pr ompt, enter :
! t s t t cm
Or , from the oper ati ng system prompt, enter:
t s t t c m
Your resul ts are i n the fi l e t es t 2. dat . Use the l oad command to l oad the fi l e
i nto MATLAB and exami ne the model output. The pr oduced fi l e t es t 2. dat
shoul d be the same as the contents i n t e s t 1. dat fi l e except thr ee zeros has
been added to the begi nni ng of the t e s t 2. dat fi l e.
Once you have generated C code for a model , you can edi t the code to opti mi ze
i t for your appl i cati on.
RTW G uidelines
A-9
RTW Guidelines
Thi s secti on provi des a br i ef summary of some gui del i nes that appl y to
Real -Ti me Workshop code gener ati on tasks. I t i ncl udes:
Wr i ti ng MEX-Fi l e S-Functi ons for RTW
Bl ock Names and Code Generati on
Writing MEX-File S-Functions for RTW
Remember these gui del i nes any ti me you generate code from a model :
The MEX-fi l e cannot cal l any MATLAB r outi nes.
I f the MEX-fi l e uses any routi nes fr om the MEX External I nterface Li brar y,
i ncl ude c g_mat r x . h i nstead of mex . h. To handl e thi s case, make sur e the
l i nes bel ow are present i n your MEX-fi l e:
#i f de f MATLAB_MEX_FI LE
#i ncl ude me x. h
#el s e
#i ncl ude c g_mat r x . h
#endi f
c g_mat r x defi nes al l of these functi ons as macr os:
- mxGe t M
- mxGe t N
- mxGe t Pr
- mxGe t St r i ng
- mxSe t M
- mxSe t N
- mxSe t Pr
- mxCr eat e Ful l
- mxFr ee Mat r i x
A RTW and C om m unications
A-10
Al l other MEX l i brar y cal l s are unsupported outsi de of the MEX i nter face.
Bracket them wi th the statements
#i f def MATLAB_MEX_FI LE
#e ndi f
Onl y real , ful l matri ces are suppor ted.
Make sur e that cal l s to mx Ge t St r i ng do not speci fy a return val ue.
I f you speci fy a r etur n val ue for mxGet St r i ng, the MEX-fi l e wi l l not compi l e
cor rectl y due to a l i mi tati on of the mx Ge t St r i ng macr o pr ovi ded i n c g_mat r x .
Obtai n the desi red str i ng through the functi ons second argument, whi ch
returns a poi nter to the stri ng.
Make sur e that the #def i ne S_FUNCTI ON_NAME statement i s corr ect. The
speci fi ed S-functi on name must match the fi l ename.
See the Real-Time Workshop Users Guide for mor e i nfor mati on on MEX-fi l e
S-functi ons.
Block Names and Code Generation
Bl ock names cannot end wi th an aster i sk () i f you want to compi l e code fr om
the model . Real -Ti me Workshop creates a comment i n the C code that i ncl udes
the bl ock name. I f you have a masked system that i ncl udes other bl ocks and
whose names ends wi th , the C code comment wi l l i ncl ude the stri ng /. Thi s
wi l l pr obabl y pr oduce a syntax err or , but coul d compi l e and produce
unexpected resul ts.
Lim itations A nd N otes
A-11
Limitations And Notes
RTW can gener ate code wi th C coded S-functi ons onl y. You cannot generate
code wi th a M coded S-functi on. There ar e a few di spl ay bl ocks that cannot be
used wi th RTW. The M-functi on bl ocks i n the tool box ar e:
I n addi ti on, the Convol uti on Decode bl ock can be used wi th RTW onl y when the
Trel l i s Fi gure Pl ot Length i s set to be zero, whi ch means that no tr el l i s wi l l be
pl otted.
When Convol uti on Encode bl ock and/or Convol uti on Decode bl ock i s pr esented
i n the bl ock di agr am, you have to set the bui l d command as fol l ows:
make_nr t OPTS=- Di nf =1. e 100
The reason for doi ng so i s that the transfer functi on i nputted to the
Convol uti on Encode bl ock and Convol uti on Decode bl ock uses i nf i n the i nput.
Blocks Library
Eye Patter n Di agram Sour ce/Si nk
Err or Rate Meter Sour ce/Si nk
A RTW and C om m unications
A-12

B
Bi bl i ography
B Bibliography
B-2
Benedetto, S., E. Bi gl i er i , and V. Castel l ani , 1987, Digital Transmission
Theory, Prenti ce-Hal l , I nc. Engl ewood Cl i ffs, NJ.
I SBN0-13-214313-5 TK5103.7.B46.
Best, Rol and E., 1993, Phase-Locked Loops: Theory, Design and Applications,
McGr aw-Hi l l Book Company, New York, NY.
I SBN 0-07-911386-9 TK7872P38B48.
Bl ack, H.S., 1953, Modulation Theory, D.Van Nostr and Company, I nc,
Pri nceton, NJ. TK 5101 B55.
Cadzow, J.A., and H.F. Van Landi ngham, 1985, Signals, Systems, and
Transforms, Prenti ce-Hal l , I nc. Engl ewood Cl i ffs, NJ.
I SBN0-13-004151-3 TK7871.6.C627.
Campopi ano, C.N., B.G. Gl azer, 1962, A Coher ent Di gi tal Ampl i tude and
Phase Modul ati on Scheme, I RE trans. CS-10:90-95.
Cassandr as, Chr i stos G., 1993, Discrete Event Systems, Modeling and
Performance Analysis, I r wi n and Aksen Associ ate I nc. Boston, MA. I SBN
0-256-11212-6 T57.6.C38.
Cahn, C.R., 1960, Combi ned Di gi tal Phase and Ampl i tude Modul ati on
Communi cati on Systems, I RE trans. CS-8:150-155.
Chen, D. and C. Mol er, Symbolic Math Toolbox, The MathWor ks, I nc., Nati ck,
MA.
Cheng, Davi d K., 1989, Field and Wave Electromagnetics, Addi son Wesl ey,
Readi ng, MA. I SBN 0-201-12819-5 QC760.C48.
Compton, R.T. Jr ., 1988, Adaptive Antennas, Concepts and Performance,
Prenti ce-Hal l , I nc. Engl ewood Cl i ffs, NJ.
I SBN0-13-004151-3 TK7871.6.C627.
Couch, Leon W. I I , 1993, Digital and Analog Communication Systems,
Macmi l l an Publ i shi ng Company, New Yor k, NY.
I SBN 0-02-325281-2 TK5101.C69.
Cover , T.M. and J.A. Thomas, 1991, Elements of I nformation Theory, John
Wi l ey and Sons, New York, NY.
I SBN 0-471-06259-6 Q360.C68.
B-3
For ney, G.D., R.G. Gal l ager , G.R. Lang, F.M. Longstaff, and S.U. Qureshi ,
1984, Effi ci ent Modul ati on for Band-Li mi ted Channel s, I EEE J ournal
SAC-2:632-646.
Foschi ni , G.J., R.D. Gi tl i n, and S.B. Wei nstei n, 1974, Opti mi zati on of Two
Di mensi onal Si gnal Constel l ati ons i n the Presence of Gaussi an Noi se, I EEE
trans. COM-22:28-38.
Freeman, Roger L., 1991, Telecommunication transmission handbook, John
Wi l ey and Sons, New York, NY.
I SBN 0-471-51816-6 TK 5101.F66.
Gagl i ar di , Robert M., 1988, I ntroduction to Communications Engineering,
John Wi l ey and Sons, New Yor k, NY.
I SBN0-471-85644-4 TK 5101.G24.
Gar dner , F.M. Char ge-pump phase-l ock l oops, I EEE Trans. on
Communications, Vol . 28, No. 11, pp 1894-1858, Nov, 1980.
Gar dner , F.M. Phase accur acy of charge pump PLLs, I EEE Trans. on
Communications, Vol . 30, No 10, pp 2362-2363, Oct. 1982.
Ger sho, A. and R.M. Gr ay, 1991, Vector quantization and signal compression,
Kl uwer Academi c Publ i shers, Boston, MA.
I SBN 07923-9181-0, TK5102.5.G45.
Gr ace, A., A.J. Laub, J.N. Li ttl e, C.M. Thompson, Control System Toolbox, The
MathWorks, I nc., Nati ck, MA.
Gr ay, R.M, 1990, Source Coding Theory, Kl uwer Academi c Publ i shers, Boston,
MA. I SBN 0-7923-9048-2, TK5102.5.G69.
Gr uber , J.J. and G. Wi l l i ams, 1992, Transmission Performance of Evolving
Telecommunications Networks, Ar tech House, Boston, MA.
I SBN 0-89006-591-8, TK5102.5.G753.
Hal sal l , F., 1992, Data Communications, Computer Networks and Open
Systems, Thi r d Edi ti on, Addi son Wesl ey, Readi ng, MA.
I SBN 0-201-56506-4 TK5105.H35.
Hambl ey, Al l an R., 1989, An I ntroduction to Communication Systems,
Computer Sci ence Pr ess, New York, NY.
I SBN 0-7167-8184-0 TK 5103.7.H36.
B Bibliography
B-4
Handel , Rai ner , Manfr ed N. Huber , and Stefan Schroder, 1994, ATM
Networks, Concepts, Protocols, Applications, Second Edi ti on, Addi son Wesl ey,
Readi ng, MA. I SBN 0-201-42274-3.
Hel str om, Carl W., 1995, Elements of Signal Detection & Estimation,
Prenti ce-Hal l , I nc. Engl ewood Cl i ffs, NJ.
I SBN0-13-808940-X TK6588.H45.
Hayki n, S, 1994, Communication Systems, John Wi l ey and Sons, New Yor k,
NY. I SBN0-471-57178-8 TK 5101.G24H37.
I mmi nk, Kees A.S., 1991, Coding Techniques for Digital Recorders,
Prenti ce-Hal l , I nc. Engl ewood Cl i ffs, NJ.
I SBN 0-13-140047-9 TK 5102.S34.
Jer uchi m, C.J, P. Bal aban, and K.S. Shanmugan, 1992, Simulation of
Communication Systems, Pl unum Pr ess, New Yor k, NY.
I SBN 0-306-43989-1 TK5102.5.J47.
Krauss, T.P., L. Shur e, and J.N. Li ttl e, 1993, Signal Processing Toolbox, The
MathWorks, I nc., Nati ck, MA.
Lee, B.G., M. Kang, and J. Lee, 1993, Broadband Telecommunications
Technology, Ar tech House, Boston, MA.
I SBN 0-89006-653-X, TK5103.7.L43.
Lee, Edwar d A., Davi d G. Messerschmi tt, 1994, Digital Communication,
second edi ti on, Kl uwer Academi c Publ i sher s, Boston, MA.
I SBN 0-7923-9391-0, TK5103.7.L44.
Lee, W.C.Y., 1989, Mobile Cellular Telecommunication Systems, McGr aw-Hi l l
Book Company, New York, NY.
I SBN 0-07-037030-3 TK6570.M6L35.
Li n, Shu and Costel l o, Dani el J. Jr ., 1983, Error Control Coding, Prenti ce-Hal l ,
I nc. Engl ewood Cl i ffs, NJ.
I SBN 0-13-283796-X QA268.L55.
Lucky, R.W, and J.C. Hancock, 1962, On the Opti mum Per for mance of N-ary
Systems Havi ng Two Degrees of Freedom, I RE trans. CS-10:185-192.
Lynch, Thomas J., 1985, Data Compression Techniques and Applications, Van
Nostand Rei nhol d, New Yor k, NY.
I SBN 0-534-03418-7 QA 76.9.D33L96.
B-5
Macl ean, T.S.M., 1986, Principles of antennas: wire and aperture, Cambri dge
Uni versi ty Pr ess, Cambri dge, U.K.
I SBN 0-521-30668 X TK7871.6.M33.
Mar al , G. and Bousquet, M., 1993, Satellite Communications Systems, John
Wi l ey and Sons, New York, NY.
I SBN 0-471-93032 TK 5104.M3613.
Mar ti n, James, 1988, Data Communication Technology, Pr enti ce-Hal l , I nc.
Engl ewood Cl i ffs, NJ.
I SBN 0-13-196643-x 025 TK5105.M3558.
Meyr , Hei nr i ch and Aschei d, Gerd, 1990, Synchronization in Digital
Communications, Vol . 1, Phase- Frequency-Locked Loops, and Ampl i tude
Contr ol , John Wi l ey and Sons, New Yor k, NY.
I SBN 0-0471-50193-X (v.1) TK 5103.7.M49.
Mi l l er , Mi chael J. and Ahamed, Syed, 1988, Digital Transmission Systems and
Networks, Vol . 2, Appl i cati ons, Computer Sci ence Pr ess, Rockvi l l e, MD. I SBN
0-88175-094-8 (v1)
I SBN 0-88175-176-6 (v2) TK5103.7.M5.5.
Ni chol son, Davi d L., 1988, Spread Spectrum Signal Design, LPE and AJ
Systems, Computer Sci ence Pr ess, Rockvi l l e, MD.
I SBN 0-88175-102-2 TK5102.5.N49.
Oppenhei m, Al an V. and Schafer, Ronal d W., 1975, Digital Signal Processing.
Proaki s, J.G. and M. Sal ehi , 1994, Communication Systems Engineering,
Prenti ce-Hal l , I nc. Engl ewood Cl i ffs, NJ.
I SBN 0-13-158932-6 TK 5101.P75.
Ramo, S., J.R. Whi nner y, and T.V. Duzer, 1994, Fields and Waves in
Communication Electronics, John Wi l ey and Sons, New York, NY. I SBN
0-471-58551-3 QC665.E4R36.
Ri chhari a, M., 1995, Satellite Communication Systems, Design Principles,
McGr aw-Hi l l Book Company, New Yor k, NY.
I SBN 0-07-052374-6.
Rosenfel d, Azr i el and Kak, Avi nash, C., 1982, Digital Picture Processing, Vol .
1, I SBN 0-12-597301-2 TA1630.R6.7.
B Bibliography
B-6
Schwartz, Mi scha, 1980, I nformation Transmission, Modulation, and Noise a
Unified Approach to Communication Systems, McGr aw-Hi l l Book Company,
New Yor k, NY. I SBN 0-07-055782-9 TK5101.S3.
Seni or, J.M, 1992, Optical Fiber Communications, Principles and Practice,
Second Edi ti on, Pr enti ce-Hal l , I nc. Engl ewood Cl i ffs, NJ. I SBN0-13-635426-2
TK5103.59.S46.
Si mon, Mar vi n K., Sami M. Hi nedi , and Wi l l i am C. Li ndsey, 1995, Digital
Communication Techniques, Signal Design and Detection, Prenti ce-Hal l , I nc.
Engl ewood Cl i ffs, NJ.
I SBN0-13-200610-3 TK7872.F73S75.
Skl ar , Bernard, 1988, Digital Communications: Fundamentals and
Applications, Prenti ce-Hal l , I nc. Engl ewood Cl i ffs, NJ. I SBN 0-13-211939-0 TK
5103.7.S55.
Stearns, S.D. and D.R. Hush, 1990, Digital Signal Analysis, Pr enti ce-Hal l , I nc.
Engl ewood Cl i ffs, NJ.
I SBN0-13-582016-2 TK5103.7.S52.
Sti rl i ng, R.C., 1987, Microwave Frequency Synthesizer, Prenti ce- Hal l , I nc.
Engl ewood Cl i ffs, NJ. I SBN0-13-213117-X TK5.102.5S698.
Taub, Her bert and Schi l l i ng, Donal d L., 1986, Principles of Communication
Systems, McGr aw-Hi l l Book Company, New York, NY. I SBN 0-07-055782-9
TK5101.S3.
Thomas, C.M, M.Y. Wei dner , and S.H. Dur rani , 1974, Di gi tal
Ampl i tude-Phase Keyi ng wi th M-ary Al phabets, I EEE trans.
COM-22:168-180.
Tzannes, Ni col aos S., 1985, Communication and Radar Systems,
Prenti ce-Hal l , I nc. Engl ewood Cl i ffs, NJ.
I SBN0-13-153545-5 TK6575.T95.
Ungerboeck, G, 1982, Channel Codi ng wi th Mul ti l evel /Phase Si gnal s, I EEE
trans. I T-28:55-67.
Ungerboeck, G., 1987, Tr el l i s-Coded Modul ati on wi th Redundant Si gnal Sets,
Par t I : I ntr oducti on, I EEE Communication Magazine, Vol . 25, No. 2, pp5-11.
Ungerboeck, G., 1987, Tr el l i s-Coded Modul ati on wi th Redundant Si gnal Sets,
Par t I I : State of the Art, I EEE Communication Magazine, Vol . 25, No. 2,
pp12-21.
B-7
Van Trees, Har ry L., 1968, Detection, Estimation, and Modulation Theory,
John Wi l ey and Sons, I nc., New York, NY.
Vel dhui s, Raymond, and Marcel Br eeuwer , 1993, An I ntroduction to Source
Coding, Prenti ce-Hal l , I nc. Engl ewood Cl i ffs, NJ.
I SBN 0-13-489089-2 TK 5102.5.V45.
Vi ter bi , Andr ew J., 1995, CDMA Principles of Spread Spectrum
Communication, Addi son Wesl ey, Readi ng, MA.
I SBN 0-201-63374-4 TK5103.45.V57.
Webb, Wi l l i am T., and Lajos Hanzo, 1994, Modern Quadrature Amplitude
Modulation, Principles and Applications for Fixed and Wireless
Communications, I EEE Press, New York, NY.
I SBN 0-7273-1701-6.
Wi l son, Stephen G., 1996, Digital Modulation and Coding, Pr enti ce-Hal l , I nc.
Engl ewood Cl i ffs, NJ.
I SBN 0-13-210071-1 TK 5100.9.W55.
Zayed, A.I ., 1993, Advances in Shannons Sampling Theory, CRC Pr ess, Ann
Arbor , MI . I SBN 0-8493-4293-7 QA276.6.Z316.
B Bibliography
B-8
Index
I-1
Symbols
-Law Compr essor bl ock 6-51
-Law Expander bl ock 6-52
A
addi ti on i n GF(q
M
) 3-136
addi ti ve whi te Gaussi an noi se (AWGN) 3-5
ADM CE wi th Carr i er bl ock 6-151
ADM wi th Car r i er bl ock 6-133
A-l aw compander 3-19
A-Law Compr essor bl ock 6-49
A-Law Expander bl ock 6-50
al phabet si ze. See M-ar y number 3-9
AM wi th Carr i er bl ock 6-131
AM Wi th Carr i er CE bl ock 6-150
anal og modul ati on/demodul ati on passband refer -
ence tabl e 6-114
ar bi trar y constel l ati on 3-76
Ar ray Functi on bl ock 6-307
ar r ay functi ons 3-128
AWGN (addi ti ve whi te Gaussi an noi se) 3-5
AWGN Channel bl ock 6-263
B
baseband anal og demodul ati on 3-92
baseband anal og modul ati on 3-90
baseband channel s 3-121
baseband di gi tal demodul ati on 3-97
baseband di gi tal modul ati on 3-93
Baseband Model PLL bl ock 6-17, 6-259, 6-266,
6-267, 6-281
baseband modul ati on demodul ati on 3-89
BCH code 3-33
BCH Code Vi ew Tabl e bl ock 6-63
BCH Decode Sequence I n/Out bl ock 6-72
BCH Decode Vector I n/Out bl ock 6-68
BCH decodi ng 3-36
BCH Encode Sequence I n/Out bl ock 6-70
BCH Encode Vector I n/Out bl ock 6-66
BCH encodi ng 3-34
Bi nary Vector Noi se Generator bl ock 6-13
bi t er ror r ate 3-12
bl ock names
for code generati on A-10
burst err or cor recti on code 3-36
C
C l anguage
gener ati ng code fr om a model A-2
Cal cul ati ons i n Gal oi s fi el ds 3-130
CDMA (code di vi si on mul ti pl e access) 3-110
channel reference tabl e 6-262
channel s 3-120
baseband 3-121
fadi ng 3-121
passband 3-120
Rayl ei gh noi se 3-121
Ri ci an noi se 3-121
Char ge Pump PLL bl ock 6-34, 6-279
ci r cl e constel l ati on 3-75
code di vi si on mul ti pl e access (CDMA) 3-110
code gener ati on A-2
exampl e A-5
gui del i nes A-9
val i d bl ock names A-10
code r ate 3-23
codebook 3-14
trai ni ng of 3-16
Coherence MFSK Cor r Demod bl ock 6-227
Coherence MFSK Demod bl ock 6-175
Coherence MFSK Demod CE bl ock 6-203
Index
I-2
coher ent demodul ati on 3-81, 3-92
coher ent vs. noncoher ent demodul ati on 3-92
Communi cati ons Tool box 1-6
i nstal l ati on 1-5
or gani zati on 1-6
Compl ex Fi l ter bl ock 6-260
constel l ati on 3-68
ar bi trar y 3-76
ci r cl e 3-75
square 3-74
constel l ati on si ze. See M-ar y number
constr ai nt l ength 3-23
conti nuous phase shi ft-keyi ng methods (MFSK
and MSK) 3-96
convol uti onal code 3-37
transfer functi ons 3-38
convol uti onal code transfer functi ons
bi nary form 3-40
nonl i near form 3-41
octal for m 3-40
state space for m 3-41
Convol uti onal Decode Sequence I n/Out bl ock
6-108
Convol uti onal Decode Vector I n/Out bl ock 6-104
convol uti onal decodi ng 3-44
har d deci si on decodi ng 3-46
soft deci si on decodi ng 3-44
Convol uti onal Encode Sequence I n/Out bl ock
6-106
Convol uti onal Encode Vector I n/Out bl ock 6-102
convol uti onal encodi ng 3-44
Costas phase-l ocked l oop 3-56
Cycl i c code 3-33
Cycl i c Decode Sequence I n/Out bl ock 6-95
Cycl i c Decode Vector I n/Out bl ock 6-92
Cycl i c Encode Sequence I n/Out bl ock 6-93
Cycl i c Encode Vector I n/Out bl ock 6-91
cycl otomi c coset 3-137
cycl otomi c cosets of GF(q
M
) 3-137
D
data buffer i ng 2-16
data compr essi on 2-3
data fl ow si mul ati on 2-10
deci si on poi nt 3-8
demappi ng 3-8
demo bl ocks 2-6
demodul ati on
coher ent 3-81, 3-82, 3-92
coher ent vs. noncoher ent 3-92
Costas phase-l ocked l oop 3-56
effect of l owpass fi l ter s on 3-54
noncoher ent 3-93
di ffer ences between Si mul i nk and MATLAB si mu-
l ati on 2-10
di ffer enti al pul se code modul ati on (DPCM) 3-20
di gi tal mod/demod map/demap baseband r efer ence
tabl e 6-185
di gi tal modul ati on 2-3
di gi tal TDMA 3-107
Di scr ete Ti me Modul e I ntegr ator bl ock 6-289
Di scr ete Ti me VCO bl ock 6-300
di spl ay devi ces 3-3, 3-5, 3-7
di storti on
of a quanti zed si gnal 3-15
doubl e-si deband suppressed carr i er ampl i tude
modul ati on and demodul ati on 3-56
doubl e-si deband wi th tr ansmi ssi on car ri er ampl i -
tude modul ati on and demodul ati on 3-57
DPCM (di ffer enti al pul se code modul ati on) 3-20
DPCM Decode bl ock 6-48
DPCM Encode bl ock 6-46
DSB ADM bl ock 6-116
Index
I-3
DSB ADM CE bl ock 6-138
DSB-SC AM bl ock 6-115
DSB-SC AM CE bl ock 6-137
D-TDMA Demux bl ock 6-240
D-TDMA Mux bl ock 6-238
E
Edge Detector bl ock 6-303
Envel ope Detector bl ock 6-302
envel ope, fadi ng 6-14
equi val ent systemati c l i near code 3-31
Er ror Counter bl ock 6-305
Er ror Rate Meter bl ock 6-35
er ror -control codi ng 2-3
code r ate 3-23
constrai nt l ength 3-23
l i near code 3-23
er ror -control codi ng r eference tabl e 6-54
er ror -rate anal ysi s 3-12
extensi on fi el ds 3-130
eye-pattern 6-28
Eye-Patter n & Scatter Pl ot bl ock 6-28
eye-pattern di agrams 3-8
eye-pattern pl ot 2-14
F
fadi ng channel s 3-121
fadi ng envel ope 6-14
FDM bl ock 6-124
FDM CE bl ock 6-144
FDMA (frequency di vi si on mul ti pl e access) 3-108
fi l ters
Hi l ber t tr ansfor m 3-118
r ai sed cosi ne 3-113
si nc 3-118
transmi tti ng and recei vi ng 3-113
FM (fr equency modul ati on) 3-65
FM bl ock 6-122
FM CE bl ock 6-142
frequency di vi si on mul ti pl e access (FDMA) 3-108
frequency modul ati on (FM) and demodul ati on
3-65
G
Gal oi s fi el ds
cal cul ati ons i n 3-130
extensi on fi el ds 3-130
pr i me fi el ds 3-130
Gaussi an noi se 3-5
Gaussi an Random Noi se Generator bl ock 6-9
gener ator matr i x 3-30
gener ator pol ynomi al 3-33
GF(q) 3-130
other r el ated functi ons 3-138
pol ynomi al s over 3-131
GF(q
M
) 3-132
addi ti on i n 3-136
cycl otomi c cosets of 3-137
mi ni mal poyl oni al s over 3-137
mul ti pl i cati on i n 3-136
pol ynomi al roots i n 3-138
H
Hammi ng code 3-32
Hammi ng Decode Sequence I n/Out bl ock 6-61
Hammi ng Decode Vector I n/Out bl ock 6-58
Hammi ng di stance 3-46
survi vor 3-47
Hammi ng Encode Sequence I n/Out bl ock 6-59
Hammi ng Encode Vector I n/Out bl ock 6-57
Index
I-4
har d deci si on decodi ng 3-44, 3-46
Hi l bert tr ansfor m fi l ter 3-118
I
i ndependent, i denti cal l y di str i buted (i .i .d) 6-8
i nput/output
sequenti al format 3-27
vector for mat 3-26
vector vs. sequenti al for mat 3-25
i nstal l ati on 1-5
i ntegr ati on
modul o 3-127
schedul ed reset 3-128
wi ndowed 3-128
K
K-Step Del ay bl ock 6-291
L
l i near bl ock code 3-30
syndrome 3-31
Li near Bl ock Decode Sequence I n/Out bl ock
6-100
Li near Bl ock Decode Vector I n/Out bl ock 6-97
Li near Bl ock Encode Sequence I n/Out bl ock
6-98
Li near Bl ock Encode Vector I n/Out bl ock 6-96
l i near code 3-23
equi val ent systemati c 3-31
Li near i zed Baseband Model PLL bl ock 6-283
l og l i kel i hood
i n soft deci si on decodi ng 3-44
M
makefi l e See templ ate makefi l e
M-ar y ampl i tude shi ft-keyi ng modul ati on (MASK)
3-71
M-ar y number 3-9, 6-211
M-ar y phase shi ft-keyi ng (MPSK) modul ati on
3-87
M-ar y quadrature shi ft-keyi ng (MQSK) modul ati on
3-73
MASK (M-ar y shi ft-keyi ng modul ati on) 3-71
MASK Demap bl ock 6-215
MASK Demod bl ock 6-159
MASK Demod CE bl ock 6-188
MASK Map bl ock 6-213
MASK Mod bl ock 6-157
MASK Mod CE bl ock 6-187
MATLAB 1-3
mean and var i ance 3-129
Mean and Vari ance bl ock 6-312
memoryl ess codes 3-37
metr i c
i n soft deci si on decodi ng 3-46
MEX-fi l es A-9
MFSK Map bl ock 6-225
MFSK Mod bl ock 6-173
MFSK Mod CE bl ock 6-202
Mi n/Max Demap bl ock 6-226
Mi n/Max I ndex bl ock 6-306
mi ni mal pol ynomi al over GF(q
M
) 3-137
mi ni mum/maxi mum i ndex 3-128
m-l aw compander 3-18
modul ati on
baseband anal og 3-90
baseband di gi tal 3-93, 3-97
di gi tal 2-3
passband and baseband 3-52
modul ati on and demodul ati on 3-52
Index
I-5
baseband 3-89
constel l ati on 3-68
doubl e-si deband suppressed car ri er ampl i tude
3-56
doubl e-si deband wi th tr ansmi ssi on carr i er am-
pl i tude 3-57
frequency 3-65
passband anal og 3-53
passband di gi tal 3-67
quadr atur e ampl i tude modul ati on (QAM) and
demodul ati on 3-62
si gnal space 3-68
si ngl e-si deband suppr essed carr i er ampl i tude
3-60
types of 3-69
Modul o bl ock 6-310
modul o i ntegr ati on 3-127
Modul o I ntegr ator bl ock 6-290
modul o operati on 3-129
MPSK (M-ary phase shi ft-keyi ng) modul ati on
3-87
MPSK Cor rel ati on Demodul ati on bl ock 6-233
MPSK Demod bl ock 6-181
MPSK Demod CE bl ock 6-206
MPSK Map bl ock 6-232
MPSK Mod bl ock 6-179
MPSK Mod CE bl ock 6-205
MQSK (M-ary quadrature shi ft-keyi ng) 3-73
mul ti pl e access 2-3
si gnal mul ti pl e access 3-104
mul ti pl e access reference tabl e 6-237
N
noi se
Gaussi an 3-5
Poi sson random i nteger 3-7
Rayl ei gh 3-6
Ri ci an 3-6
uni for m 3-7
noncentr al i ty par ameter of Ri ci an noi se 3-6
Noncoherence MFSK Cor r Demod bl ock 6-229
Noncoherence MFSK Demod bl ock 6-177
Noncoherence MFSK Demod CE bl ock 6-204
noncoherent demodul ati on 3-82, 3-93
Number Counter bl ock 6-304
number of err or bi ts 3-12
number of symbol err ors 3-12
O
or gani zati on of thi s manual 1-6
P
par i ty-check matri x 3-31
par ti ti on
trai ni ng of 3-16
vector 3-14
passband and baseband modul ati on 3-52
passband channel s 3-120
passband di gi tal modul ati on and demodul ati on
3-67
PDM bl ock 6-127
PDM CE bl ock 6-146
PLL bl ock 6-32, 6-277
PM bl ock 6-125
PM CE bl ock 6-145
Poi sson Random I nteger Gener ator bl ock 6-12
Poi sson random i nteger noi se 3-7
pol ynomi al roots i n GF(q
M
) 3-138
pol ynomi al s over GF(q) 3-131
pr edi cti ve quanti zati on 3-19
pr edi ctor 3-20
pr i me fi el ds 3-130
Index
I-6
Q
QADM bl ock 6-120
QADM CE bl ock 6-140
QAM (quadratur e ampl i tude modul ati on) 3-62
QAM bl ock 6-118
QAM CE bl ock 6-139
QASK Demap Ar bi trar y Constel l ati on bl ock
6-224
QASK Demap Ci rcl e Constel l ati on bl ock 6-221
QASK Demap Square Constel l ati on bl ock 6-218
QASK Demod Arbi tr ary Constel l ati on bl ock
6-171
QASK Demod CE Ar bi tr ar y Constel l ati on bl ock
6-200
QASK Demod CE Ci r cl e Constel l ati on bl ock
6-196
QASK Demod CE Square Constel l ati on bl ock
6-192
QASK Demod Ci r cl e Constel l ati on bl ock 6-167
QASK Demod Squar e Constel l ati on bl ock 6-163
QASK Map Arbi tr ary Constel l ati on bl ock 6-222
QASK Map Ci r cl e Constel l ati on bl ock 6-219
QASK Map Squar e Constel l ati on bl ock 6-216
QASK Mod Arbi tr ar y Constel l ati on bl ock 6-169
QASK Mod CE Arbi tr ary Constel l ati on bl ock
6-198
QASK Mod CE Ci r cl e Constel l ati on bl ock 6-194
QASK Mod CE Squar e Constel l ati on bl ock
6-190
QASK Mod Ci r cl e Constel l ati on bl ock 6-165
QASK Mod Squar e Constel l ati on bl ock 6-161
quadr atur e ampl i tude modul ati on (QAM) and de-
modul ati on 3-62
Quanti zati on Decode bl ock 6-45
quanti zed si gnal di stor ti on 3-15
R
rai sed cosi ne fi l ter 3-113
Rai sed Cosi ne Fi l ter bl ock 6-251
random er ror-cor recti on code 3-36
random si gnal generators 3-5
Rayl ei gh Fadi ng CE Channel bl ock 6-269
Rayl ei gh noi se 3-6
Rayl ei gh Noi se CE Channel bl ock 6-271
Rayl ei gh noi se channel 3-121
Rayl ei gh Noi se Generator bl ock 6-14
Real -Ti me Wor kshop 1-4, A-1
gui del i nes A-9
Reed-Sol omon code 3-36
Reed-Sol omon Decode Bi nar y Sequence I n/Out
bl ock 6-89
Reed-Sol omon Decode Bi nar y Vector I n/Out bl ock
6-80
Reed-Sol omon Decode I nteger Sequence I n/Out
bl ock 6-84
Reed-Sol omon Decode I nteger Vector I n/Out bl ock
6-76
Reed-Sol omon Encode Bi nary Vector I n/Out bl ock
6-78
Reed-Sol omon Encode I nteger Sequence I n/Out
bl ock 6-82
Reed-Sol omon Encode I nteger Vector I n/Out bl ock
6-74
refer ence tabl es for MATLAB functi ons 5-4
Regi ster Shi ft bl ock 6-295
Ri ci an noi se 3-6
Ri ci an Noi se CE Channel bl ock 6-273
Ri ci an noi se channel 3-121
Ri ci an Random Noi se Gener ator bl ock 6-15
Index
I-7
S
Sampl ed Read From Workspace bl ock 6-22
scal ar quanti zati on 3-13
scal ar to vector conver si on 3-128
Scal ar to Vector Conver ter bl ock 6-308
scatter pl ot 3-11, 6-28
schedul ed r eset i ntegrati on 3-128
Schedul ed Reset I ntegr ator bl ock 6-293
sequenti al i nput/output for mat 3-27
S-functi ons A-9
si gnal gener ators and di spl ay devi ces 3-3
si gnal gener ators, random 3-5
Si gnal Pr ocessi ng Tool box 1-3
Si gnal Quanti zer bl ock 6-40
si gnal space 3-68
si mul ati on
data fl ow 2-10
di fferences between Si mul i nk and MATLAB
2-10
ti me fl ow 2-10
SI MULI NK 1-4
Si nc bl ock 6-257
si nc fi l ter 3-118
si ngl e-si deband suppr essed car ri er ampl i tude
modul ati on and demodul ati on 3-60
soft deci si on decodi ng 3-44
l og l i kel i hood 3-44
metri c 3-46
source codi ng 2-3, 3-13
source codi ng r eference tabl e 6-39
sources and si nks r eference tabl e 6-6
square constel l ati on 3-74
SSB ADM bl ock 6-130
SSB ADM CE bl ock 6-149
SSB-AM bl ock 6-128
SSB-AM CE bl ock 6-147
survi vor 3-47
symbol deci si on. See demappi ng 3-8
symbol er ror r ate 3-12
symbol i nter val 6-210
synchroni zati on 3-123, 6-276
baseband PLL si mul ati on 3-125
syndrome 3-31
systemati c code 3-23
systemati c l i near code 3-30
T
TDMA (ti me di vi si on mul ti pl e access) 3-107
TDMA, di gi tal 3-107
templ ate makefi l e
modi fyi ng A-3
ti me di vi si on mul ti pl e access (TDMA) 3-107
ti me fl ow si mul ati on 2-10
Ti me-share Demux bl ock 6-244
Ti me-Shar e Mux bl ock 6-242
transfer functi ons
bi nar y form 3-40
nonl i near form 3-41
octal for m 3-40
state space for m 3-41
transfer functi ons convol uti onal code 3-38
transfer pr obabi l i ty 3-45
transmi ssi on del ay 2-15
transmi tti ng and recei vi ng fi l ter s 3-113
transmi tti ng/r ecei vi ng fi l ter s r eference tabl e
6-250
trel l i s pl ot 3-48
Tri gger ed Buffer Down bl ock 6-297
Tri gger ed Read Fr om Wor kspace bl ock 6-18
Tri gger ed Si gnal Quanti zer bl ock 6-43
Tri gger ed Wri te To Workspace bl ock 6-25
Index
I-8
U
uni form noi se 3-7
Uni for m Random I nteger Generator bl ock 6-11
Uni for m Random Noi se Gener ator bl ock 6-8
uti l i ti es 3-126
uti l i ty refer ence tabl e 6-287
V
Varyi ng AWGN Channel bl ock 6-265
Varyi ng Rayl ei gh Fadi ng CE Channel bl ock
6-270
Varyi ng Rayl ei gh Noi se Channel CE bl ock
6-272
Varyi ng Ri ci an Noi se Channel CE bl ock 6-274
VCO (vol tage contr ol l ed osci l l ator) 3-127
VCO bl ock 6-301
vector i nput/output format 3-26
vector par ti ti on 3-14
Vector Pul se bl ock 6-23
Vector Redi str i butor bl ock 6-246
Vector to Scal ar Converter bl ock 6-309
vector vs. sequenti al i nput/output 3-25
Vi ter bi al gori thm 3-47
Vi ter bi method 3-44
har d deci si on decodi ng 3-44
soft deci si on decodi ng 3-44
vol tage control l ed osci l l ator (VCO) 3-127
W
wi ndowed i ntegr ati on 3-128
Wi ndowed I ntegr ator bl ock 6-292

You might also like