handouts for dsp

Upload: krajasekarantuti

Post on 02-Jun-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/10/2019 Handouts for DSP

    1/211

    DSP and Digital Filters (2014-5289)

    DSP & Digital Filters

    Mike Brookes

  • 8/10/2019 Handouts for DSP

    2/211

    1: Introduction

    1: IntroductionOrganization

    Signals

    ProcessingSyllabus

    Sequences

    Time Scaling

    -TransformRegion ofConvergence

    -Transform examples

    Rational z-Transforms

    Rational example

    nverse z-TransformMATLAB routines

    Summary

    DSP and Digital Filters (2014-5289)

  • 8/10/2019 Handouts for DSP

    3/211

    Organization

    1: Introduction

    OrganizationSignals

    ProcessingSyllabus

    Sequences

    Time Scaling

    -TransformRegion ofConvergence

    -Transform examples

    Rational z-Transforms

    Rational example

    nverse z-TransformMATLAB routines

    Summary

    DSP and Digital Filters (2014-5289)

    18 lectures: feel free to ask questions

    Textbooks: (a) Mitra Digital Signal Processing ISBN

    most of the course except for some of t (b) Harris Multirate Signal Processing IS

    covers multirate material in more detailMitra

    Lecture slides available via Blackboard or on myhttp://www.ee.ic.ac.uk/hp/staff/dmb/courses/d

    quite dense - ensure you understand each l email me if you dont understand or dont a

    Prerequisites: 3rd year DSP - attend lectures if

    Exam + Formula Sheet (past exam papers + so

    Problems: Mitra textbook contains many problechapter and also MATLAB exercises

  • 8/10/2019 Handouts for DSP

    4/211

    Signals

    1: Introduction

    Organization

    SignalsProcessingSyllabus

    Sequences

    Time Scaling

    -TransformRegion ofConvergence

    -Transform examples

    Rational z-Transforms

    Rational example

    nverse z-TransformMATLAB routines

    Summary

    DSP and Digital Filters (2014-5289)

    A signal is a numerical quantity that is a functioindependent variables such as time or position.

    Real-world signals are analog and vary continuocontinuous values.

    Digital signals are sampled at discrete times andfinite number of discrete values

    We will mostly consider one-dimensionsal real-vregular sample instants; except in a few places, quantization.

    Extension to multiple dimensions and compis mostly straighforward.

    Examples:

  • 8/10/2019 Handouts for DSP

    5/211

    Processing

    1: Introduction

    Organization

    Signals

    ProcessingSyllabusSequences

    Time Scaling

    -TransformRegion ofConvergence

    -Transform examples

    Rational z-Transforms

    Rational example

    nverse z-TransformMATLAB routines

    Summary

    DSP and Digital Filters (2014-5289)

    Aims to improve a signal in some way or extfrom it

    Examples:

    Modulation/demodulation

    Coding and decoding

    Interference rejection and noise suppress

    Signal detection, feature extraction

    We are concerned with linear, time-invariant p

  • 8/10/2019 Handouts for DSP

    6/211

    Syllabus

    1: Introduction

    Organization

    Signals

    Processing SyllabusSequences

    Time Scaling

    -TransformRegion ofConvergence

    -Transform examples

    Rational z-Transforms

    Rational example

    nverse z-TransformMATLAB routines

    Summary

    DSP and Digital Filters (2014-5289)

    Main topics:

    Introduction/Revision

    Transforms

    Discrete Time Systems

    Filter Design

    FIR Filter Design

    IIR Filter Design

    Multirate systems

    Multirate Fundamentals

    Multirate Filters Subband processing

  • 8/10/2019 Handouts for DSP

    7/211

    Sequences

    1: Introduction

    Organization

    Signals

    ProcessingSyllabus

    SequencesTime Scaling

    -TransformRegion ofConvergence

    -Transform examples

    Rational z-Transforms

    Rational example

    nverse z-TransformMATLAB routines

    Summary

    DSP and Digital Filters (2014-5289)

    We denote the nth sample of a signal as x[n] wherethe entire sequence as {x[n]} although we will ofte

    Special sequences:

    Unit step: u[n] =

    1 n 0

    0 otherwise

    Unit impulse: [n] = 1 n= 0

    0 otherwise

    Condition: condition[n] =

    1 condition is true

    0 otherwise

    Right-sided: x[n] = 0 forn < Nmin Left-sided: x[n] = 0 forn > Nmax Finite length: x[n] = 0 forn / [Nmin, Nmax]

    Causal: x[n] = 0 forn

  • 8/10/2019 Handouts for DSP

    8/211

    Time Scaling

    1: Introduction

    Organization

    Signals

    ProcessingSyllabus

    Sequences

    Time Scaling-Transform

    Region ofConvergence

    -Transform examples

    Rational z-Transforms

    Rational example

    nverse z-TransformMATLAB routines

    Summary

    DSP and Digital Filters (2014-5289)

    For sampled signals, the nth sample is at time t=n

    is the sample frequency.Often easiest to scale time so that fs = 1 Hz. E.g. low-pass filter for fs = 44.1kHz we can design a 0.fs = 1 Hz.

    To scale back to real-world values: Every quantityomultiplied by Tn (or equivalently by fns ). Thus alT and all frequenciesand angular frequenciesbyT

    We use for real angular frequencies and for nfrequency. The units of are radians per sample.

    Warning: Several MATLAB routines scale time so tnon-standard and irritating.

  • 8/10/2019 Handouts for DSP

    9/211

    z-Transform

    1: Introduction

    Organization

    Signals

    ProcessingSyllabus

    Sequences

    Time Scaling

    z-TransformRegion ofConvergence

    -Transform examples

    Rational z-Transforms

    Rational example

    nverse z-TransformMATLAB routines

    Summary

    DSP and Digital Filters (2014-5289)

    The z-transform converts a sequence, {x[n]}, into aarbitrary complex-valued variable z.

    Why do it?

    Complex functions are easier to manipulate than

    Useful operations on sequences correspond to sithe z-transform:

    addition, multiplication, scalar multiplicatioconvolution

    Definition: X(z) =+

    n= x[n]zn

  • 8/10/2019 Handouts for DSP

    10/211

    Region of Convergence

    1: Introduction

    Organization

    Signals

    ProcessingSyllabus

    Sequences

    Time Scaling

    -Transform

    Region ofConvergence

    -Transform examples

    Rational z-Transforms

    Rational example

    nverse z-TransformMATLAB routines

    Summary

    DSP and Digital Filters (2014-5289)

    The set ofz for which X(z)converges is its Region

    Complex analysis: the ROC of a power series (if an annular region of the form 0 Rmin < |z| < Rm

    X(z)will alwaysconverge absolutelyinside the ROsome, all, or none of the boundary.

    converge absolutely

    +n= |x[n]z

    n

    finite Rmin = 0, Rmax = ROC may included either, both or none of

    absolutely summable X(z)converges for |z|

    right-sided Rmax = causal X()converges

    left-sided Rmin = 0 anticausal X(0)converges

  • 8/10/2019 Handouts for DSP

    11/211

    z-Transform examples

    DSP and Digital Filters (2014-5289)

    The sample at n= 0 is indicated by an open circle.

    u[n] 11z1 1

    x[n] 2z2 + 2 + z1 0

    x[n 3] z3

    2z2 + 2 + z1

    0

    nu[n]=0.81

    1z1

    nu[n 1] 11z1 0

    nu[n] z1

    12z1+z2 1

    sin(n)u[n]=0.5z1 sin()

    12z1 cos()+z2 1

    cos(n)u[n]=0.51z1 cos()

    12z1 cos()+z2 1

    Note: Examples 4 and 5 have the same z-transform but different R

    Geometric Progression:r

    n=qn

  • 8/10/2019 Handouts for DSP

    12/211

    Rational z-Transforms

    1: Introduction

    Organization

    Signals

    ProcessingSyllabus

    Sequences

    Time Scaling

    -TransformRegion ofConvergence

    -Transform examples

    Rationalz-Transforms

    Rational example

    nverse z-Transform

    MATLAB routines

    Summary

    DSP and Digital Filters (2014-5289)

    Most z-transforms that we will meet arerational pocoefficients, usually one polynomial in z1 divided b

    G(z) =gMm=1(1zmz

    1)Kk=1(1pkz

    1) =gzKM

    Mm=1(zzm)Kk1(zpk)

    Completely defined by thepoles,zerosandgain.

    Theabsolute valuesof the poles define the ROCs:R+ 1 different ROCs

    where R is the number of distinct pole ma

    Note: There are K M zeros or M Kpoles at

  • 8/10/2019 Handouts for DSP

    13/211

    Rational example

    1: Introduction

    Organization

    Signals

    ProcessingSyllabus

    Sequences

    Time Scaling

    -TransformRegion ofConvergence

    -Transform examples

    Rational z-Transforms

    Rational examplenverse z-Transform

    MATLAB routines

    Summary

    DSP and Digital Filters (2014-5289)

    G(z) = 82z1

    44z13z2

    Poles/Zeros: G(z) = 2z(z0.25))(z+0.5)(z1.5)Polesat z = {0.5, +1.5)},

    Zerosat z = {0, +0.25}

    Partial Fractions: G(z) = 0.751+0.5z1 + 1.2511.5z1

    ROC ROC 0.751+0.5z11.25

    11.5z1

    a 0 |z|

  • 8/10/2019 Handouts for DSP

    14/211

    Inverse z-Transform

    1: Introduction

    Organization

    Signals

    ProcessingSyllabus

    Sequences

    Time Scaling

    -TransformRegion ofConvergence

    -Transform examples

    Rational z-Transforms

    Rational example

    Inversez-TransformMATLAB routines

    Summary

    DSP and Digital Filters (2014-5289)

    g[n] = 12j G(z)zn1dz where the integral is anti-

    circle within the ROC, z=Rej

    .Proof:1

    2j

    G(z)zn1dz= 12j

    m= g[m]z

    m

    zn

    (i)=

    m= g[m] 12j

    znm1d

    (ii)= m= g[m][n m]=g[n]

    (i) depends on the circle with radius R lying within

    (ii) Cauchys theorem: 12j

    zk1dz=[k] forz =dzd

    =jRej 12j

    zk1dz= 12j2=0 R

    k1e

    = Rk

    2 2=0 ej=Rk(k)=

    In practice use a combination of partial fractions an

  • 8/10/2019 Handouts for DSP

    15/211

    MATLAB routines

    1: Introduction

    Organization

    Signals

    ProcessingSyllabus

    Sequences

    Time Scaling

    -TransformRegion ofConvergence

    -Transform examples

    Rational z-Transforms

    Rational example

    nverse z-Transform MATLAB routinesSummary

    DSP and Digital Filters (2014-5289)

    tf2zp,zp2tf b(z1)

    a(z1) {zm, pk, g}

    residuez b(z1)

    a(z1)

    krk

    1pkz1

    tf2sos,sos2tf b(z1)

    a(z1)

    l

    b0,l+b1,lz1+b2,lz

    1+a1,lz1+a2,lz2

    zp2sos,sos2zp {zm, pk, g}

    l

    b0,l+b1,lz1+b2,l

    1+a1,lz1+a2,l

    zp2ss,ss2zp {zm, pk, g} x =Ax + Bu

    y=Cx + Du

    tf2ss,ss2tf b(z1)

    a(z1)

    x =Ax + Bu

    y=Cx + Du

  • 8/10/2019 Handouts for DSP

    16/211

    Summary

    1: Introduction

    Organization

    Signals

    ProcessingSyllabus

    Sequences

    Time Scaling

    -TransformRegion ofConvergence

    -Transform examples

    Rational z-Transforms

    Rational example

    nverse z-TransformMATLAB routines

    Summary

    DSP and Digital Filters (2014-5289)

    Time scaling: assume fs = 1 Hz so <

    z-transform: X(z) =+

    n= x[n]n

    ROC: 0 Rmin < |z| < Rmax Causal: ROC Absolutely summable: |z| = 1 ROC

    Inversez-transform: g[n] = 12j G(z)zn1dz

    Not uniqueunless ROC is specified Usepartial fractionsand/or atable

    For further

  • 8/10/2019 Handouts for DSP

    17/211

    2: Three Different Fourier T

    2: Three DifferentFourier Transforms

    Fourier Transforms

    Convergence ofDTFT

    DTFT Properties

    DFT Properties

    Symmetries

    Parsevals Theorem

    Convolution

    Sampling Process

    Zero-Padding

    Phase Unwrapping

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5289)

  • 8/10/2019 Handouts for DSP

    18/211

    Fourier Transforms

    2: Three DifferentFourier Transforms

    Fourier TransformsConvergence ofDTFT

    DTFT Properties

    DFT Properties

    Symmetries

    Parsevals Theorem

    Convolution

    Sampling Process

    Zero-Padding

    Phase Unwrapping

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5289)

    Three different Fourier Transforms:

    Continuous-Time Fourier Transform (CTFT): Discrete-Time Fourier Transform (DTFT):x[ Discrete Fourier Transform (DFT):x[n] X

    Forward Transform Inve

    CTFT X(j) = x(t)e

    jtdt x(t) = 12

    DTFT X(e

    j

    ) = x[n]e

    jn

    x[n] =

    1

    2

    DFT X[k] =N1

    0 x[n]ej2 kn

    N x[n] = 1N

    We use forreal and = T fornormalized aNyquist frequency is = 2 fs2 =

    T

    and =.

    For power signals (energy time interval), CTFT

    unbounded.Fix this by normalizing:

    X(j) = limA12A

    AA x(t)e

    jtdt

    X(ej) = limA12A

    AA x[n]e

    jn

  • 8/10/2019 Handouts for DSP

    19/211

    Convergence of DTFT

    2: Three DifferentFourier Transforms

    Fourier Transforms

    Convergence ofDTFTDTFT Properties

    DFT Properties

    Symmetries

    Parsevals Theorem

    Convolution

    Sampling Process

    Zero-Padding

    Phase Unwrapping

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5289)

    DTFT:X(ej) = x[n]e

    jn does not conver

    Consider the finite sum: XK(ej

    ) =

    K

    Kx[n]ej

    Strong Convergence:x[n] absolutely summable X(ej) converges

    |x[n]| < supX(ej) XK(ej)

    Weaker convergence:

    x[n] finite energy X(ej

    ) converges inmean |x[n]|

    2< 12

    X(ej) XK(e

    Example: x[n] = sin0.5nn

    0 0.1 0.2 0.3 0.4 0.5-0.2

    0

    0.20.4

    0.6

    0.8

    1

    /2 (rad/sample)

    K

    j

    K=5

    0 0.1 0.2 0.3 0.4 0.5-0.2

    0

    0.20.4

    0.6

    0.8

    1

    /2 (rad/sample)

    K

    j

    K=20

    0 0.1 0.2-0.2

    0

    0.20.4

    0.6

    0.8

    1

    /2 (r

    K

    j

    Gibbs phenomenon:Converges at each as K but peak error d

  • 8/10/2019 Handouts for DSP

    20/211

    [DTFT Convergence Proofs]

    DSP and Digital Filters (2014-5289) Fourier

    (1) Strong Convergence: [these

    We are given that

    |x[n]| < >0, Nsuch that

    |n|>N

    For K N, supX(ej ) XK(ej)= sup |n|>Kx[n]ejn

    sup

    |n|>K

    x[n]ejn(2) Weak Convergence:

    We are given that

    |x[n]|2 < >0, Nsuch that|n|>N

    Define y[K][n] =

    0 |n| K

    x[n] |n| > Kso that its DTFT is, Y[K](ej ) =

    We see that X(ej ) XK(e

    j ) = x[n]e

    jn KKx[n]e

    j

    =|n|>Kx[n]e

    jn = y

    [K][n

    From Parsevals theorem,

    y[K][n]2 = 12

    Y[K](ej )2 d= 1

    2

    X(ej) XK(eHence for K N, 1

    2

    X(ej ) XK(ej)2 d = y[K][n]

  • 8/10/2019 Handouts for DSP

    21/211

    DTFT Properties

    2: Three DifferentFourier Transforms

    Fourier Transforms

    Convergence ofDTFT

    DTFT PropertiesDFT Properties

    Symmetries

    Parsevals Theorem

    Convolution

    Sampling Process

    Zero-Padding

    Phase Unwrapping

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5289)

    DTFT:X(ej) = x[n]e

    jn

    DTFTisperiodicin : X(e

    j(+2m

    ) =X(e

    j

    ) DTFTis the z-Transformevaluated at the poin

    X(z) = x[n]z

    n

    DTFT converges iff the ROC includes |z| = 1.

    DTFTis the same as the CTFT of a signal comthe sample times(dirac delta functions) :

    x(t) =

    x[n](t nT)=x(t) (

    Equivalent to multiplying a continuousx(t)by a

    Proof: X(ej) =

    x[n]ejn

    n= x[n]

    (t nT)e

    j tT

    (i)

    =n= x[n](t nT)e

    j

    (ii)=

    x(t)e

    jtdt

    (i) OK if |x[n]| < . (ii) use = T

  • 8/10/2019 Handouts for DSP

    22/211

    DFT Properties

    2: Three DifferentFourier Transforms

    Fourier Transforms

    Convergence ofDTFT

    DTFT Properties

    DFT PropertiesSymmetries

    Parsevals Theorem

    Convolution

    Sampling Process

    Zero-Padding

    Phase Unwrapping

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5289)

    DFT:X[k] =N1

    0 x[n]ej2 kn

    N

    DTFT:X(ej) = x[n]ejn

    Case 1: x[n] = 0 forn / [0, N 1]

    DFT is the same as DTFT at k = 2N

    k.

    The {k} are uniformly spaced from = 0 to

    DFT is the z-Transform evaluated at N equaaround the unit circle beginning at z= 1.

    Case 2: x[n] is periodic with period N

    DFT equals the normalized DTFT

    X[k] = limKN

    2K+1 XK(ejk

    )

    where XK(ej) =

    KKx[n]e

    jn

  • 8/10/2019 Handouts for DSP

    23/211

    Symmetries

    2: Three DifferentFourier Transforms

    Fourier Transforms

    Convergence ofDTFT

    DTFT Properties

    DFT Properties

    SymmetriesParsevals Theorem

    Convolution

    Sampling Process

    Zero-Padding

    Phase Unwrapping

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5289)

    Ifx[n] has a special property then X(ej)and X[k]properties as shown in the table (and vice versa):

    One domain Other d

    Discrete PerioSymmetric Symm

    Antisymmetric Antisym

    Real Conjugate SImaginary Conjugate An

    Real + Symmetric Real + SyReal + Antisymmetric Imaginary + A

    Symmetric: x[n] =x[n]

    X(ej) =X(ej)X[k] =X[(k)mod N] =X[N k] fo

    Conjugate Symmetric: x[n] =x[n]Conjugate Antisymmetric: x[n] = x[n]

  • 8/10/2019 Handouts for DSP

    24/211

    Parsevals Theorem

    2: Three DifferentFourier Transforms

    Fourier Transforms

    Convergence ofDTFT

    DTFT Properties

    DFT Properties

    Symmetries

    ParsevalsTheorem

    Convolution

    Sampling Process

    Zero-Padding

    Phase Unwrapping

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5289)

    Fourier transforms preserveenergy

    CTFT

    |x(t)|2

    dt= 12

    |X(j)|

    2

    dDTFT

    |x[n]|

    2= 12

    X(ej)

    2 d

    DFT N1

    0 |x[n]|2

    = 1N

    N10 |X[k]|

    2

    More generally, they actually preservecomplex inne

    N10 x[n]y[n] = 1N

    N10 X[k]Y[k]

    Unitary matrix viewpoint for DFT:

    If we regard x and Xas vectors, then X = Fxwa symmetric matrix defined by fk+1,n+1 =e

    j2

    The inverse DFT matrix is F1 = 1NFH

    equivalently, G = 1NF is aunitary matrixwith

  • 8/10/2019 Handouts for DSP

    25/211

    Convolution

    2: Three DifferentFourier Transforms

    Fourier Transforms

    Convergence ofDTFT

    DTFT Properties

    DFT Properties

    Symmetries

    Parsevals Theorem

    ConvolutionSampling Process

    Zero-Padding

    Phase Unwrapping

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5289)

    DTFT:Convolution Productx[n] =g[n] h[n]=

    k=g[k]h[n k]

    X(ej) =G(ej)H(ej)

    DFT:Circular convolutionProductx[n] =g[n] Nh[n]=

    N1k=0 g[k]h[(n k)mo

    X[k] =G[k]H[k]

    DTFT:Product Circular Convolution 2

    y[n] =g[n]h[n] Y(ej) = 12G(e

    j) H(ej) = 12G(

    DFT:ProductCircular ConvolutionNy[n] =g[n]h[n]

    X[k] = 1N

    G[k] NH[k]

    g[n] : h[n] : g[n] h[n] : g

  • 8/10/2019 Handouts for DSP

    26/211

    Sampling Process

    DSP and Digital Filters (2014-5289)

    Time Time

    Analog CT

    Low PassFilter

    * CT

    Sample DT

    Window DT

    DFT DF

  • 8/10/2019 Handouts for DSP

    27/211

  • 8/10/2019 Handouts for DSP

    28/211

    Phase Unwrapping

    2: Three DifferentFourier Transforms

    Fourier Transforms

    Convergence ofDTFT

    DTFT Properties

    DFT Properties

    Symmetries

    Parsevals Theorem

    Convolution

    Sampling Process

    Zero-Padding

    Phase UnwrappingSummary

    MATLAB routines

    DSP and Digital Filters (2014-5289)

    Phase of a DTFT is only defined to within an integ

    -20

    2

    4

    6

    (

    x[n] |X

    -2 0 2

    -2

    0

    2

    (rad/sample)-2

    -40

    -20

    0

    (

    X[k] X[k]

    Phase unwrapping adds multiples of2 onto each phase as continuous as possible.

  • 8/10/2019 Handouts for DSP

    29/211

    Summary

    2: Three DifferentFourier Transforms

    Fourier Transforms

    Convergence ofDTFT

    DTFT Properties

    DFT Properties

    Symmetries

    Parsevals Theorem

    Convolution

    Sampling Process

    Zero-Padding

    Phase Unwrapping

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5289)

    Three types: CTFT, DTFT, DFT

    DTFT = CTFT of continuous signal

    DFT = DTFT of periodic or finite suppo

    DFT is a scaled unitary transform

    DTFT: Convolution Product; Product

    DFT: Product Circular Convolution

    DFT: Zero Padding Denser freq sampling

    Phase is only defined to within a multiple of2

    Whenever you integrate frequency component

    12 for CTFT and DTFT or

    1N

    for DFT

    Inverse transform, Parseval, frequency do

    For further details see Mitra: 3 & 5.

  • 8/10/2019 Handouts for DSP

    30/211

    MATLAB routines

    2: Three DifferentFourier Transforms

    Fourier Transforms

    Convergence ofDTFT

    DTFT Properties

    DFT Properties

    Symmetries

    Parsevals Theorem

    Convolution

    Sampling Process

    Zero-Padding

    Phase Unwrapping

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5289)

    fft, ifft DFT with optional zero-padd

    fftshift swap the two halves of a vecconv convolution or polynomial multipliccircular)

    x[n]y[n] real(ifft(fft(x).*fft(y)))unwrap remove 2 jumps from phase spe

  • 8/10/2019 Handouts for DSP

    31/211

    3: Discrete Cosine Tra

    3: Discrete CosineTransform

    DFT Problems

    DCTDCT of sine waveDCT/DFTEquivalence

    DCT Properties

    DCT

    Energy Conservation

    Energy Compaction

    Frame-based coding

    Lapped Transform

    MDCT (ModifiedDCT)MDCT & TDAC

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5349)

  • 8/10/2019 Handouts for DSP

    32/211

    DFT Problems

    3: Discrete CosineTransform

    DFT ProblemsDCTDCT of sine waveDCT/DFTEquivalence

    DCT Properties

    DCT

    Energy Conservation

    Energy Compaction

    Frame-based coding

    Lapped Transform

    MDCT (ModifiedDCT)MDCT & TDAC

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5349)

    For processing 1-D or 2-D signals (especially codingto divide the signal into frames and then apply aneach frame that compresses the information into few

    The DFT has some problems when used for this pu

    N real x[n] N complex X[k] : 2 real, N2

    DFT the DTFT of a periodic signal formed Spurious frequency components from boun

    N=20f=0.08

    The Discrete Cosine Transform (DCT) overcomes t

  • 8/10/2019 Handouts for DSP

    33/211

    DCT

    3: Discrete CosineTransform

    DFT Problems

    DCTDCT of sine waveDCT/DFTEquivalence

    DCT Properties

    DCT

    Energy Conservation

    Energy Compaction

    Frame-based coding

    Lapped Transform

    MDCT (ModifiedDCT)MDCT & TDAC

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5349)

    To form the Discrete Cosine Transform (DCT), replreverse order and insert a zero between each pair of

    0 12

    y[r]

    Take the DFT of length 4Nreal symmetric sequenc

    Result is real, symmetric and anti-periodic: only ne

    012

    23

    Y[k]

    Forward DCT: XC[k] =N1

    n=0 x[n]cos2(2n+1)k

    4N fo

    Compare DFT: XF[k] =N1

    n=0 x[n]expj2(4n+0)

    4N

  • 8/10/2019 Handouts for DSP

    34/211

    DCT of sine wave

    3: Discrete CosineTransform

    DFT Problems

    DCT DCT of sine waveDCT/DFTEquivalence

    DCT Properties

    DCT

    Energy Conservation

    Energy Compaction

    Frame-based coding

    Lapped Transform

    MDCT (ModifiedDCT)MDCT & TDAC

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5349)

    DCT: XC[k] =N1

    n=0 x[n]cos2(2n+1)k

    4N

    f= mN f= mN

    x[n]N=20f=0.10

    N=20f=0.08

    |XF[k]|

    |XC[k]|

    DFT: RealComplex; Freq range [0, 1]; Poorly unless f= m

    N; |XF[k]| k

    1 forNf < kDCT: RealReal; Freq range [0, 0.5]; Well loca

    |XC[k]| k2 for2Nf < k < N

  • 8/10/2019 Handouts for DSP

    35/211

    DCT/DFT Equivalence

    3: Discrete CosineTransform

    DFT Problems

    DCTDCT of sine wave

    DCT/DFTEquivalence

    DCT Properties

    DCT

    Energy Conservation

    Energy Compaction

    Frame-based coding

    Lapped Transform

    MDCT (ModifiedDCT)MDCT & TDAC

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5349)

    XC[k] =N1n=0 x[n]cos

    2(2n+1)k4N

    Define y[r] =

    0 r even

    xr12

    r= 1 : 2 : 2N 1

    x4N1r

    2

    r= 2N+ 1 : 2 : 4N

    YF[k] = 4N1r=0 y[r]W

    kr4N where WM =e

    j2M

    (i)=2N1

    n=0 y[2n + 1]W(2n+1)k4N

    (ii)=N1

    n=0 y[2n+ 1]W(2n+1)k4N

    +N1

    m=0y[4N 2m 1]W(4N2m4N

    (iii)=x[n]W

    (2n+1)k4N +

    N1m=0x[m]W

    (2m+4N

    = 2N1

    n=0 x[n]cos2(2n+1)k

    4N = 2XC[k]

    (i) odd r only: r= 2n + 1, (ii) reverse order for n

    (iii) substitute y definition & W4Nk4N =ej2 4Nk

    4N

  • 8/10/2019 Handouts for DSP

    36/211

    DCT Properties

    3: Discrete CosineTransform

    DFT Problems

    DCTDCT of sine waveDCT/DFTEquivalence

    DCT PropertiesDCT

    Energy Conservation

    Energy Compaction

    Frame-based coding

    Lapped Transform

    MDCT (ModifiedDCT)MDCT & TDAC

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5349)

    Definition: X[k] =N1

    n=0 x[n]cos2(2n+1)k

    4N

    Linear: x[n] + y[n] X[k] + Y[k] DFTConvolutionMultiplication propert Symmetric: X[k] =X[k] sincecos k= c Anti-periodic: X[k+ 2N] = X[k] because:

    cos(+ ) = cos 2(2n + 1)(k+ 2N) = 2(2n + 1)k+ 8

    X[N] = 0 since X[N] =X[N] = X[N Periodic: X[k+ 4N] = X[k+ 2N] =X[k]

    DCT basis functions:

    0:

    3:

    1: 4:

    2: 5:

  • 8/10/2019 Handouts for DSP

    37/211

    IDCT

    3: Discrete CosineTransform

    DFT Problems

    DCTDCT of sine waveDCT/DFTEquivalence

    DCT Properties

    IDCTEnergy Conservation

    Energy Compaction

    Frame-based coding

    Lapped Transform

    MDCT (ModifiedDCT)MDCT & TDAC

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5349)

    y[r] = 14N4N1

    k=0 Y[k]Wrk4N =

    12N

    4N1k=0 X[k]W

    x[n] =y[2n + 1] = 12N4N1

    k=0 X[k]W(2n+1)k

    4N (i)= 12N

    2N1k=0 X[k]W

    (2n+1)k4N

    12N2N1

    l=0 X[l]W(2n+1)(l+2N)4N

    (ii)= 1

    N2N1k=0 X[k]W

    (2n+1)k4N

    (iii)= 1N

    X[0] + 1N

    N1k=1 X[k]W

    (2n+1)k4N +

    1N

    X

    + 1N

    N1r=1 X[2N r]W

    (2n+1)(24N

    (iv)= 1

    NX[0] + 1

    N

    N1k=1 X[k]W

    (2n+1)k4N

    + 1N

    N1r=1 X[r]W

    (2n+1)r+2N4N

    x[n] = 1

    N

    X[0] + 2

    N

    N1

    k=1

    X[k]cos 2(2n+1)k

    4N

    = Inv

    (i) k=l+ 2N fork 2N and X[k+ 2N] = X[

    (ii) (2n+1)(l+2N)4N = (2n+1)l

    4N + n + 12

    (iii) k= 2N r fork > N (iv) X[N] = 0 and

  • 8/10/2019 Handouts for DSP

    38/211

    Energy Conservation

    3: Discrete CosineTransform

    DFT Problems

    DCTDCT of sine waveDCT/DFTEquivalence

    DCT Properties

    DCT

    EnergyConservation

    Energy Compaction

    Frame-based coding

    Lapped Transform

    MDCT (ModifiedDCT)

    MDCT & TDAC

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5349)

    DCT: X[k] =N1

    n=0 x[n]cos2(2n+1)k

    4N

    IDCT: x[n] = 1NX[0] +

    2NN1

    k=1 X[k]cos2(2n+1)

    4N

    rep

    0 12 23

    y[r]

    DFT 0

    12

    Y[k]

    Energy: E=N1n=0 |x[n]|

    2: E 2E 8N E 0

    E= 1N

    |X|2

    [0] + 2N

    N1n=1 |X|

    2[n]

    Orthogonal DCT(preserves energy)

    Define: c[k] =

    2kN

    c[0] =

    1N

    , c[k= 0

    ODCT: X[k] =c[k]N1n=0 x[n]cos

    2(2n+1)k4N

    IODCT: x[n] =N1

    k=0 c[k]X[k]cos2(2n+1)k

    4N

    Note: MATLAB dct

  • 8/10/2019 Handouts for DSP

    39/211

  • 8/10/2019 Handouts for DSP

    40/211

    Frame-based coding

    3: Discrete CosineTransform

    DFT Problems

    DCTDCT of sine waveDCT/DFTEquivalence

    DCT Properties

    DCT

    Energy Conservation

    Energy Compaction

    Frame-basedcoding

    Lapped Transform

    MDCT (ModifiedDCT)

    MDCT & TDAC

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5349)

    Divide continuous signalinto frames

    Apply DCT to each frame

    Encode DCT

    e.g. keep only 30X[k]

    Apply IDCT y[n]

    x[n]

    X[k]

    y[n]

    y[n]-x[n]

    Problem: Coding may create discontinuities at frame.g. JPEG, MPEG use 8 8 pixel blocks

    8.3 kB (PNG) 1.6 kB (JPEG) 0

  • 8/10/2019 Handouts for DSP

    41/211

    Lapped Transform

    3: Discrete CosineTransform

    DFT Problems

    DCTDCT of sine waveDCT/DFTEquivalence

    DCT Properties

    DCT

    Energy Conservation

    Energy Compaction

    Frame-based coding

    Lapped TransformMDCT (ModifiedDCT)MDCT & TDAC

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5349)

    Modified Discrete Cosine Transform(MDCT): over

    x[0 : 2N 1]MDCT

    X0[0 :N 1]IMDCT

    y0[0 : 2N 1]

    x[N : 3N 1]MDCT

    X1[N : 2N 1]

    IMDCT y1[N : 3N 1]

    x[2N : 4N 1]MDCT

    X2[2N : 3N 1]IMDCT

    y2[2N : 3N 1]

    y[n] =y0[n] + y1[n] + y2[n]

    X0[k]

    y0[n]

    X1[k]

    y1[n]

    X

    y

    y[n]

    y[n]-x[n] = error

    x[n]

    0 N

    N

    MDCT: 2N N coefficients,IMDCT: N 2N saAddyi[n] together to get y[n]. Only two non-zero tErrors cancel exactly: Time-domain alias cancellatio

  • 8/10/2019 Handouts for DSP

    42/211

    MDCT (Modified DCT)

    3: Discrete CosineTransform

    DFT Problems

    DCTDCT of sine waveDCT/DFTEquivalence

    DCT Properties

    DCT

    Energy Conservation

    Energy Compaction

    Frame-based coding

    Lapped Transform

    MDCT (ModifiedDCT)

    MDCT & TDAC

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5349)

    MDCT: XM[k] =2N1

    n=0 x[n]cos2(2n+1+N)(

    8N

    IMDCT: yA,B[n] = 1N

    N1k=0 XM[k]cos 2

    (2n+

    MDCT from a DCT of length 2N:

    Split x[n] into four N2-vectors:x=

    a b c d

    Form the N-vectoru=

    d c a

    b

    wherec is in reverse order

    Form v=

    u u

    Take 2N DCT: v VC

    Symmetry VC[2k] = 0

    Set XM[k] =VC[2k+ 1]

    a

    -c 100.

    Example: M= 103, N= 104:

    Direct: 2M N= 2 107with DFT: 12 (M+ N)log2(M+ N) = 1.8

    But: (a) DFT may be very long ifN is large(b) No output samples until all x[n]has been i

  • 8/10/2019 Handouts for DSP

    57/211

  • 8/10/2019 Handouts for DSP

    58/211

    Overlap Save

    4: Linear Timenvariant Systems

    LTI Systems

    ConvolutionProperties

    BIBO Stability

    Frequency Response

    Causality

    Passive and Lossless

    ConvolutionComplexity

    Circular ConvolutionFrequency-domain

    onvolution

    Overlap Add Overlap SaveSummary

    MATLAB routines

    DSP and Digital Filters (2014-5233)

    Alternative method:(1)chop x[n] into N

    K

    overlappingchunks of length K+ M 1

    (2) K+M1 each chunk with h[n](3)discard first M 1 from each chunk(4)concatenate to make y[n]

    The first M 1 points of each output chunk are in

    Operations: slightly less than overlap-add because ncreate y[n]

    Advantages:same as overlap add

    Strangely, rather less popular than overlap-add

  • 8/10/2019 Handouts for DSP

    59/211

    Summary

    4: Linear Timenvariant Systems

    LTI Systems

    ConvolutionProperties

    BIBO Stability

    Frequency Response

    Causality

    Passive and Lossless

    ConvolutionComplexity

    Circular ConvolutionFrequency-domain

    onvolution

    Overlap AddOverlap Save

    SummaryMATLAB routines

    DSP and Digital Filters (2014-5233)

    LTI systems: impulse response, frequency respo

    BIBO stable, Causal, Passive, Lossless systems Convolution and circular convolution properties

    Efficient methods for convolution single DFT overlap-add and overlap-save

    For further

  • 8/10/2019 Handouts for DSP

    60/211

    MATLAB routines

    4: Linear Timenvariant Systems

    LTI Systems

    ConvolutionProperties

    BIBO Stability

    Frequency Response

    Causality

    Passive and Lossless

    ConvolutionComplexity

    Circular ConvolutionFrequency-domain

    onvolution

    Overlap AddOverlap Save

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5233)

    fftfilt Convolution using overlap ax

    [n

    ]y

    [n

    ] real(ifft(fft(x).*fft(y)))

  • 8/10/2019 Handouts for DSP

    61/211

    5: Filters

    5: FiltersDifference Equations

    FIR Filters

    FIR SymmetriesIR Frequency

    Response

    Negating z

    Cubing z

    Scaling z

    IR Impulse responseexamples

    IR Impulse response

    Other BIBOesponses

    Stability Triangle

    Low-pass filter

    Allpass filters

    Group Delay

    Minimum Phase

    Linear Phase Filters

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

  • 8/10/2019 Handouts for DSP

    62/211

    Difference Equations

    5: Filters

    DifferenceEquations

    FIR FiltersFIR Symmetries

    IR FrequencyResponse

    Negating z

    Cubing z

    Scaling z

    IR Impulse responseexamples

    IR Impulse response

    Other BIBO

    esponsesStability Triangle

    Low-pass filter

    Allpass filters

    Group Delay

    Minimum Phase

    Linear Phase Filters

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    Most useful LTI systems can be described by a diffe

    y[n] =Mr=0 b[r]x[n r]

    N

    r

    Nr=0 a[r]y[n r] =Mr=0 b[r]x[n r]

    a[n] y[n] =b[n] x[n] Y(z) = B(z)

    A(z)X(z)

    Y(ej) = B(ej)A(ej)X(e

    j)

    (1)Alwayscausal.(2)Orderof system ismax(M, N), the highest r w(3)We assume that a[0] = 1; if not, divide A(z)an(4)Filter is BIBO stable iff roots ofA(z)all lie wit

    Notenegative signin first equation.Authors in some SP fields reverse the sign of the a[

  • 8/10/2019 Handouts for DSP

    63/211

    FIR Filters

    5: Filters

    Difference Equations

    FIR FiltersFIR SymmetriesIR Frequency

    Response

    Negating z

    Cubing z

    Scaling z

    IR Impulse responseexamples

    IR Impulse response

    Other BIBOesponses

    Stability Triangle

    Low-pass filter

    Allpass filters

    Group Delay

    Minimum Phase

    Linear Phase Filters

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    A(z) = 1: Finite Impulse Response(FIR) filter: Y(Impulse response is b[n]and is of length M+

    Frequency responseis B(ej) and is the DTFT ofbComprises Mcomplex sinusoids + const:

    b[0] +b[1]ej + +b[M]ejM

    Small Mresponse contains only low quefrencies

    Symmetrical b[n]H(ej

    )e

    jM

    2 consists of M

    2 cosin

    M=4 M=14

    0 1 2 30

    0.5

    1

    0 1 2 30

    0.5

    1

    Rule of thumb: Fastest possible transition 2M

  • 8/10/2019 Handouts for DSP

    64/211

    FIR Symmetries

    5: Filters

    Difference Equations

    FIR Filters

    FIR SymmetriesIR FrequencyResponse

    Negating z

    Cubing z

    Scaling z

    IR Impulse responseexamples

    IR Impulse response

    Other BIBOesponses

    Stability Triangle

    Low-pass filter

    Allpass filters

    Group Delay

    Minimum Phase

    Linear Phase Filters

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    B(ej)is determined by the zeros ofzMB(z) =

    Real b[n] conjugate zeSymmetric: b[n] =b[M n] reciprocal zero

    Real + Symmetric b[n] conjugate+or else pairs

    Real: Symmetric: [1, 1.28, 0.64] [1, 1.64 + 0.27j, 1]

    -1 0 1

    -1

    -0.5

    0

    0.5

    1

    z-1 0 1

    -1

    -0.5

    0

    0.5

    1

    z

    -2 0 20

    1

    2

    (rad/sample)-2 0 2

    0

    1

    2

    3

    (rad/sample)

  • 8/10/2019 Handouts for DSP

    65/211

    [FIR Symmetry Proofs]

    DSP and Digital Filters (2014-5241)

    In all of the proofs below, we assume that z=z0 is a root ofB(z)so that B

    and then we prove that this implies that other values of z also satisfy B(z)

    (1) Real b[n]

    B(z0) =M

    r=0b[r]

    z0r

    =M

    r=0b[r]

    z0r

    since b[r] is real

    = Mr=0b[r]zr0

    take complex conjugate

    = 0 = 0 since B(z0) = 0

    (2) Symmetric: b[n] = b[M n]

    B(z10 ) =M

    r=0b[r]zr0

    =

    Mn=0b[M n]z

    Mn0 substitute r= M n

    =zM

    0M

    n=0b[M n]z

    n

    0 take out zM

    0 factor=zM0

    Mn=0b[n]z

    n0 since b[M n] = b[n]

    =zM0 0 = 0 since B(z0) = 0

  • 8/10/2019 Handouts for DSP

    66/211

    IIR Frequency Response

    5: Filters

    Difference Equations

    FIR Filters

    FIR Symmetries

    IIR FrequencyResponse

    Negating z

    Cubing z

    Scaling z

    IR Impulse responseexamples

    IR Impulse response

    Other BIBOesponses

    Stability Triangle

    Low-pass filter

    Allpass filters

    Group Delay

    Minimum Phase

    Linear Phase Filters

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    Factorize H(z) = B(z)A(z) =

    b[0]M

    i=1(1qiz1)

    Ni=1(1piz

    1)

    Roots ofA(z)and B(z) are thepoles{pi} andzAlso an additional N Mzeros at the origin (affecH(ej)= |b[0]||z

    M|Mi=1|zqi||zN|

    Ni=1|zpi|

    forz=ej

    Example:

    H(z) = 2+2.4z110.96z1+0.64z2 = 2(1+1.2z

    1

    (1(0.480.64j)z1)(1(0

    At= 1.3:H(ej)= 21.761.620.39= 5.6H(ej) = (0.6 + 1.3) (1.7 + 2.2) =

    0 1 2 30

    5

    10

    -1 0 1

    -1

    -0.5

    0

    0.5

    1

    1.76 1.62

    0.39

    (z)

  • 8/10/2019 Handouts for DSP

    67/211

    Negating z

    5: Filters

    Difference Equations

    FIR Filters

    FIR SymmetriesIR Frequency

    Response

    Negating zCubing z

    Scaling z

    IR Impulse responseexamples

    IR Impulse response

    Other BIBOesponses

    Stability Triangle

    Low-pass filter

    Allpass filters

    Group Delay

    Minimum Phase

    Linear Phase Filters

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    Given a filter H(z) we can form a new one HR(z) =Negate all odd powers ofz, i.e. negate alterna

    Example: H(z) = 2+2.4z1

    10.96z1+0.64z2

    -1 0 1-1

    -0.5

    0

    0.5

    1

    (z)

    0 1 2 30

    5

    10

    Negate z: HR(z) = 22.4z1

    1+0.96z1+0.64z2 Negate o

    -1 0 1

    -1

    -0.5

    0

    0.5

    1

    (z)

    0 1 2 30

    5

    10

    Pole and zero positions arenegated, frequency resp

  • 8/10/2019 Handouts for DSP

    68/211

    Cubing z

    5: Filters

    Difference Equations

    FIR Filters

    FIR SymmetriesIR Frequency

    Response

    Negating z

    Cubing zScaling z

    IR Impulse responseexamples

    IR Impulse response

    Other BIBOesponses

    Stability Triangle

    Low-pass filter

    Allpass filters

    Group Delay

    Minimum Phase

    Linear Phase Filters

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    Given a filter H(z) we can form a new one HC(z) =Insert two zeros between each a[n]and b[n] te

    Example: H(z) = 2+2.4z1

    10.96z1+0.64z2

    -1 0 1-1

    -0.5

    0

    0.5

    1

    (z)

    -2 0 20

    5

    10

    (rad/sample)

    Cube z: HC(z) = 2+2.4z3

    10.96z3+0.64z6 Insert 2 ze

    -1 0 1

    -1

    -0.5

    0

    0.5

    1

    z-2 0 2

    0

    5

    10

    (rad/sample)

    C

    Pole and zero positions arereplicated, magnitude re

  • 8/10/2019 Handouts for DSP

    69/211

    Scaling z

    5: Filters

    Difference Equations

    FIR Filters

    FIR SymmetriesIR Frequency

    Response

    Negating z

    Cubing z

    Scaling zIR Impulse response

    examples

    IR Impulse response

    Other BIBOesponses

    Stability Triangle

    Low-pass filter

    Allpass filters

    Group Delay

    Minimum Phase

    Linear Phase Filters

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    Given a filter H(z) we can form a new one HS(z) =Multiply a[n]and b[n] byn

    Example: H(z) = 2+2.4z1

    10.96z1+0.64z2

    -1 0 1

    -1

    -0.5

    0

    0.5

    1

    (z)

    0 1 2 30

    5

    10

    Scale z: HS(z) =H( z1.1 ) =

    2+2.64z1

    11.056z1+0.7744z2

    -1 0 1

    -1

    -0.5

    0

    0.5

    1

    z0 1 2 30

    5

    10

    15

    20

    (rad/s)

    Pole and zero positions aremultiplied by , >1 Pole at z =pgives peak bandwidth 2 |log |p||For pole near unit circle,decrease bandwidthby

  • 8/10/2019 Handouts for DSP

    70/211

    IIR Impulse response examples

    5: Filters

    Difference Equations

    FIR Filters

    FIR SymmetriesIR Frequency

    Response

    Negating z

    Cubing z

    Scaling z

    IIR Impulseresponse examples

    IR Impulse response

    Other BIBOesponses

    Stability Triangle

    Low-pass filter

    Allpass filters

    Group Delay

    Minimum Phase

    Linear Phase Filters

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    To find the impulse response of B(z)A(z) , use partial fra

    Example 1: M < N

    B(z)A(z) =

    13.4z1

    10.3z10.4z2 = 3

    1+0.5z1 + 210.8z1

    h[n] = (3 (0.5)n 2 (0.8)n) u[n]Example 2: M NB(z)A(z) = 25

    .7z1

    +0.2z2

    +0.8z3

    10.3z10.4z2

    = 1 2z1 + 13.4z110.3z10.4z2= 1 2z1 + 31+0.5z1 + 210.8z1

    h[n] =[n] 2[n 1] + (3 (0.5)n 2 (0.8)n

    Example 3: repeated pole at z = 0.5B(z)A(z) =

    35z11.3z21+0.3z10.55z20.2z3

    = 21+0.5z1 + 3

    (1+0.5z1)2+ 210.8z1

    h[n] = (2 (0.5)n + 3(n + 1) (0.5)n 2 (0.8

  • 8/10/2019 Handouts for DSP

    71/211

    IIR Impulse response

    5: Filters

    Difference Equations

    FIR Filters

    FIR SymmetriesIR Frequency

    Response

    Negating z

    Cubing z

    Scaling z

    IR Impulse responseexamples

    IIR Impulseresponse

    Other BIBOesponses

    Stability Triangle

    Low-pass filter

    Allpass filters

    Group Delay

    Minimum Phase

    Linear Phase Filters

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    H(z) = B(z)A(z) we want h[n], the inverse z-Transform

    (1) Assume M < Nelse, do a long division: H(z)

    (2) Factorize A(z) =Npi=1

    1 piz1

    Ki (Np=(3) Then

    B(z)A(z) =

    Npi=1

    Kik=1

    ri,k

    (1piz1)k (K

    where ri,k =

    (pi)kKi

    (Kik)!

    dKik

    d(z1)Kik B(z)A(z) (1 p

    For the common case Ki = 1 i(e.g. all poles B(z)A(z) =

    Npi=1

    ri1piz1

    where ri=B(A(

    (4) Theimpulse responseis given by

    h[n] =Npi=1

    Kik=1 Cn+k1k1 ri,kpni forn 0

    where C = !!()! is a binomial coefficient

    For the common case Ki = 1 i: h[n] =

  • 8/10/2019 Handouts for DSP

    72/211

    [Impulse Response: Proof of (3)]

    DSP and Digital Filters (2014-5241)

    [You do not ne

    We assume thatB(z)

    A(z) =Np

    j=1Kj

    l=1

    rj,l

    (1pjz1)land we want to determin

    (1) Multiply both sides by

    1 piz1Ki :

    B(z)A(z)

    1 piz

    1Ki = Npj=1Kjl=1 rj,l(1piz1)Ki(1pjz1)l

    now separate out the term with j =i:

    B(z)A(z)

    1 piz

    1

    Ki =

    Kil=1ri,l

    1 piz

    1

    Kil +

    j=i

    Kjl=1

    rj,l(

    (1

    (2) DifferentiateKi k times with respect to z1 : d

    Kik

    d(z1)Kikand evalua

    1 k Ki Ki k < Ki so we are differentiating < Ki times.

    Hence all terms in

    j=i

    Kjl=1

    rj,l(1piz1)Ki

    (1pjz1)l will still include a fact

    numerator and will equal zero at z = pi.

    Similarly, terms inKil=1ri,l 1 piz1Kil with l < k will also vaniAlso, terms in

    Kil=1ri,l

    1 piz1

    Kil with l > k will also different

    The only term remaining is: (p)Kik (Ki k)!ri,k from which the re

    [Similarly dn

    dxn(xm)

    x=0

    is zero unless m= n i

  • 8/10/2019 Handouts for DSP

    73/211

    [Impulse Response: Proof of (4)]

    DSP and Digital Filters (2014-5241)

    [You do not ne

    We use induction on k to show that 1 pz1k = n=0

    Cn+k1

    k1

    pnz

    (1) Suppose the formula is true for k and differentiate both sides with respe

    dd(z1)

    1 pz1

    k=

    n=0Cn+k1k1 p

    nzn

    This gives:

    pk

    1 pz1

    (k+1)

    =

    n=0nC

    n+k1k1 p

    nz(n1) =

    n=1nC

    where we have omitted the term with n= 0 because it equals zero.

    Now substitute, m= n 1:

    pk

    1 pz1(k+1)

    =

    m=0(m+ 1)Cm+kk1 p

    m+1zm

    1 pz1(k+1)

    =

    m=0m+1k

    Cm+kk1 p

    mzm =

    m=0Cmk

    which proves the result for k+ 1.

    (2) To start the induction at k = 1:

    1 pz1

    1 =

    n=0Cn0pnzn =

    n=0pnzn

    This is true from the standard geometric progression formula. (Note th

  • 8/10/2019 Handouts for DSP

    74/211

    Other BIBO responses

    5: Filters

    Difference Equations

    FIR Filters

    FIR SymmetriesIR Frequency

    Response

    Negating z

    Cubing z

    Scaling z

    IR Impulse responseexamples

    IR Impulse response

    Other BIBOresponses

    Stability Triangle

    Low-pass filter

    Allpass filters

    Group Delay

    Minimum Phase

    Linear Phase Filters

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    All LTI systems described by difference equations hexponentially or exponentially times a power ofn.

    It is perfectly possible to have BIBO stable LTI systresponses decay more slowly than this.

    Example: h[n] = 11+n2 forn 0BIBO stable since

    |h[n]| = 2.077... < Hence H(e

    j

    )exists.However, no finite difference equation can have t

    0 1 0

    0.5

    1

    1.5

    2

  • 8/10/2019 Handouts for DSP

    75/211

    Stability Triangle

    5: Filters

    Difference Equations

    FIR Filters

    FIR SymmetriesIR Frequency

    Response

    Negating z

    Cubing z

    Scaling z

    IR Impulse responseexamples

    IR Impulse response

    Other BIBOesponses

    Stability TriangleLow-pass filter

    Allpass filters

    Group Delay

    Minimum Phase

    Linear Phase Filters

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    Not normally easy to tell if poles lie within

    |z

    |= 1, but

    easy test for a 2nd order filter:

    Suppose A(z) = 1 + a[1]z1 + a[2]z2

    The roots are p1,2 = a[1]

    a[1]24a[2]

    2

    Want the conditions that|p1,2| < KCase 1: Real roots:

    (P) a[1]2

    4a[2](Q)2K < a[1] a[1]2 4a[2]

  • 8/10/2019 Handouts for DSP

    76/211

    Low-pass filter

    5: Filters

    Difference Equations

    FIR Filters

    FIR SymmetriesIR Frequency

    Response

    Negating z

    Cubing z

    Scaling z

    IR Impulse responseexamples

    IR Impulse response

    Other BIBOesponses

    Stability Triangle

    Low-pass filterAllpass filters

    Group Delay

    Minimum Phase

    Linear Phase Filters

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    1st order low pass filter: extremely commony[n] = (1

    p)x[n] +py[n

    1]

    H(z) = 1

    1pz

    Impulse response:h[n] = (1 p)pn = (1 p)en

    where = 1 lnp is the time constant in sa

    Magnitude response:

    H(ej)

    = 1p

    12p cos+p2

    Low-pass filter with DC gain of unity.3 dB frequency is 3dB = cos1

    1 (1p)22p

    Compare continuous time: HC(j) = 11+j

    Indistinguishable for low but H(ej) is perio

    -1 0 1

    -1

    -0.5

    0

    0.5

    1

    (z)

    p=0.80

    0.01

    -30

    -20

    -10

    0

  • 8/10/2019 Handouts for DSP

    77/211

    Allpass filters

    5: Filters

    Difference Equations

    FIR Filters

    FIR SymmetriesIR Frequency

    Response

    Negating z

    Cubing z

    Scaling z

    IR Impulse responseexamples

    IR Impulse response

    Other BIBOesponses

    Stability Triangle

    Low-pass filter

    Allpass filtersGroup Delay

    Minimum Phase

    Linear Phase Filters

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    Ifa[n] =b[M n] we have anallpass filter

    H(ej) =M

    r=0b[r]ejr

    Mr=0b[r]e

    j(Mr) =ejMM

    r=0b[r]eMr=0b[r]

    The two sums are complex conjugatesthey haveHence

    H(ej)= 1 allpassHowever phase isnotconstant: H(ej) =M

    1st order allpass: H(z) = p+z1

    1pz1= p1p1z1

    1pz1

    Pole at p and zero at p1: reflected in unit ci

    Constant distance ratio:ej p= |p|

    ej

    0 1 2 30

    0.2

    0.4

    0.6

    0.8

    1

    0 1 2 3

    -3

    -2

    -1

    0

    In an allpass filter, thezeros are the poles reflected

  • 8/10/2019 Handouts for DSP

    78/211

    Group Delay

    5: Filters

    Difference Equations

    FIR Filters

    FIR SymmetriesIR Frequency

    Response

    Negating z

    Cubing z

    Scaling z

    IR Impulse responseexamples

    IR Impulse response

    Other BIBOesponses

    Stability Triangle

    Low-pass filter

    Allpass filters

    Group DelayMinimum Phase

    Linear Phase Filters

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    Group delay: H(ej) = dH(ej)

    d = delay of the

    Trick to get at phase: ln H(ej) = lnH(ej)+j

    H= d((lnH(ej)))

    d =

    1H(ej)

    dH(ej)d

    =

    H

    H(ej) =n=0 h[n]e

    jn= F(h[n])dH(ej)d

    =n=0

    jnh[n]ejn=

    jF(nh[n]

    H= 1H(ej)

    dH(ej)d

    =

    jF(nh[n])F(h[n])

    =

    F(F

    Example: H(z) = 11pz1 H= [1 p]=

    -1 0 1

    -1

    -0.5

    0

    0.5

    1

    (z)

    0 1 2 3

    -0.8

    -0.6

    -0.4

    -0.2

    0

    p=0.80

    0 1

    0

    1

    2

    3 p=0.80

    H

    Average group delay (over ) = (# poles # zerosZeros on the unit circle count

  • 8/10/2019 Handouts for DSP

    79/211

    [Group Delay Properties]

    DSP and Digital Filters (2014-5241)

    The group delay of a filter H(z)at a frequency , measured in seconds or sam

    of the envelope of a modulated sine wave at a frequency

    . It is defined aFor example, H(z) = zk defines a filter that delays its input by k samplegroup delay by evaluating

    H(ej ) =

    dH(ej)

    d=

    d

    d

    ejk

    =

    d

    d(k

    which tells us that this filter has a constant group delay of k samples that is

    The average value of H equals the total change in

    H(ej

    ) as goes f2. If you imagine an elastic string connecting a pole or zero to the point z goes from to+ the string will wind once around the pole or zero if it not if it is outside. Thus, the total change in H(ej) is equal to 2 times the unit circle minus the number of zeros inside the unit circle. A zero that icounts 1

    2since there is a sudden discontinuity of in H(ej) as passes

    When you multiply or divide complex numbers, their phases add or subtracyou multiply or divide transfer functions their group delays will add or sub

    the group delay of an IIR filter, H(z) = B(z)A(z)

    , is given by H = B Acan determine the group delay of a factorized transfer function by summinindividual factors.

  • 8/10/2019 Handouts for DSP

    80/211

  • 8/10/2019 Handouts for DSP

    81/211

    [Group Delay Example]

    DSP and Digital Filters (2014-5241)

    As an example, suppose we want to determine the group delay of : H(z) =

    ifH(z) = B(z)A(z) , then H = B A. In this case B = 0 so H = [1 p

    Using equation (2) gives H = F([0 p])F([1 p])

    since nh[n] = [0 1] [1

    Applying the definition of the DTFT, we get

    H =

    pej

    1 pej

    =

    p

    ej p

    =

    p

    ej p

    (ej p) (ej p)=

    As demonstrated above, the average value ofHis zero for this filter becauszero inside the unit circle.

  • 8/10/2019 Handouts for DSP

    82/211

    Minimum Phase

    5: Filters

    Difference Equations

    FIR Filters

    FIR SymmetriesIR Frequency

    Response

    Negating z

    Cubing z

    Scaling z

    IR Impulse responseexamples

    IR Impulse response

    Other BIBOesponses

    Stability Triangle

    Low-pass filter

    Allpass filters

    Group Delay

    Minimum PhaseLinear Phase Filters

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    Average group delay (over ) = (# poles # zeros

    zeros on the unit circle count Reflecting an interior zero to the exteriormultiplies

    H(ej) by a constant butincreases average group delayby 1 sample.

    -1 0 1

    -1

    -0.5

    0

    0.5

    1

    (z)

    0

    -10

    -5

    0

    -1 0 1

    -1

    -0.5

    0

    0.5

    1

    (z)

    0 -10

    0

    10

    20

    30

    H

    A filter with all zeros inside the unit circle is amini Lowest possible group delayfor a given magn Energy in h[n] isconcentrated towards n= 0

  • 8/10/2019 Handouts for DSP

    83/211

    Linear Phase Filters

    5: Filters

    Difference Equations

    FIR Filters

    FIR SymmetriesIR Frequency

    Response

    Negating z

    Cubing z

    Scaling z

    IR Impulse responseexamples

    IR Impulse response

    Other BIBOesponses

    Stability Triangle

    Low-pass filter

    Allpass filters

    Group Delay

    Minimum Phase

    Linear PhaseFilters

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    The phase of alinear phasefilter is: H(ej) =0

    Equivalentlyconstant group delay: H= dH(ej

    d

    A filter has linear phase iffh[n] issymmetricoranth[n] =h[M n]nor else h[n] = h[M

    Mcan be even ( mid point) or odd (mid Proof

    :

    2H(ej) =M0 h[n]e

    jn +M0 h[M n]ej

    =ejM2

    M0 h[n]e

    j(nM2) + h[Mh[n]symmetric:

    2H(ej) = 2ejM2

    M0 h[n]cos

    n M2

    h[n]anti-symmetric:2H(ej) = 2jejM2 M0 h[n]sin

    n M2

    = 2ej(2+

    M2)M

    0 h[n]sin

    n M2

  • 8/10/2019 Handouts for DSP

    84/211

    Summary

    5: Filters

    Difference Equations

    FIR Filters

    FIR SymmetriesIR Frequency

    Response

    Negating z

    Cubing z

    Scaling z

    IR Impulse responseexamples

    IR Impulse response

    Other BIBOesponses

    Stability Triangle

    Low-pass filter

    Allpass filters

    Group Delay

    Minimum Phase

    Linear Phase Filters

    SummaryMATLAB routines

    DSP and Digital Filters (2014-5241)

    Useful filters havedifference equations:

    Freq response determined by pole/zero pos N Mzeros at origin (or M N poles) Geometric construction of|H(ej)|

    Pole bandwidth 2 |log |p|| 2 (1 | Stable if poles have|p|

  • 8/10/2019 Handouts for DSP

    85/211

    MATLAB routines

    5: Filters

    Difference Equations

    FIR Filters

    FIR SymmetriesIR Frequency

    Response

    Negating z

    Cubing z

    Scaling z

    IR Impulse responseexamples

    IR Impulse response

    Other BIBOesponses

    Stability Triangle

    Low-pass filter

    Allpass filters

    Group Delay

    Minimum Phase

    Linear Phase Filters

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    filter filter a signal

    impz Impulse responseresiduez partial fraction expansiongrpdelay Group Delay

    freqz Calculate filter frequency resp

  • 8/10/2019 Handouts for DSP

    86/211

    6: Window Filter De

    6: Window FilterDesign

    nverse DTFT

    Rectangular windowDirichlet Kernel

    Window relationships

    Common Windows

    Uncertainty principle

    Order Estimation

    Example Design

    Frequency sampling

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

  • 8/10/2019 Handouts for DSP

    87/211

    Inverse DTFT

    6: Window FilterDesign

    Inverse DTFTRectangular windowDirichlet Kernel

    Window relationships

    Common Windows

    Uncertainty principle

    Order Estimation

    Example Design

    Frequency sampling

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    For any BIBO stable filter, H(ej) is the DTFT of

    H(ej) =

    h[n]ejn h[n] = 12H

    If we know H(ej) exactly, the IDTFT gives t

    Example: Ideal Lowpass filter

    H(ej) = 1 || 00 || > 0

    h[n] = sin0nn

    -2 0 20

    0.5

    1

    20

    0

    2/

    Note: Width in is 20, width in n is 20

    : productSadly h[n] is infiniteandnon-causal. Solution: mul

  • 8/10/2019 Handouts for DSP

    88/211

    Rectangular window

    6: Window FilterDesign

    nverse DTFT

    RectangularwindowDirichlet Kernel

    Window relationships

    Common Windows

    Uncertainty principle

    Order Estimation

    Example Design

    Frequency sampling

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    Truncate to M2 to make finite; h1[n] is now of len

    MSE Optimality:Define mean square error (MSE) in frequency do

    E= 12

    H(ej)H1(ej)2 d= 12

    H(ej)

    M2

    M2

    h1[n]ejn

    2

    d

    Minimum E is when h1[n] = (h[n])Proof: Differentiate w.r.t. h1[r]and set to zero

    However: 9%overshoot at a discontinuity even for

    0

    h1[n]

    M=14

    0 1 0

    0.5

    1

    M=14

    M=28

    Normal to delay by M2 to make causal. Multiplies H

  • 8/10/2019 Handouts for DSP

    89/211

    Dirichlet Kernel

    6: Window FilterDesign

    nverse DTFT

    Rectangular window Dirichlet KernelWindow relationships

    Common Windows

    Uncertainty principle

    Order Estimation

    Example Design

    Frequency sampling

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    TruncationMultiply h[n] by a rectangular windo

    Circular Convolution HM+1(ej

    ) =

    1

    2

    W(ej) =M

    2

    M2

    ejn(i)= 1 + 2

    0.5M1 cos(n)

    (ii)=

    Proof: (i) ej(n) + ej(+n) = 2 cos (n) (ii) Su

    Effect: convolve ideal freq response withDirichlet k

    -2 0 2

    0

    0.5

    1

    -2 0 2

    0

    0.5

    1

    4/(M+1)

    -

    0

    0.5

    1

    -2 0 2

    0

    0.5

    1M=14

    Provided that 4M+1

  • 8/10/2019 Handouts for DSP

    90/211

    [Dirichlet Kernel]

    DSP and Digital Filters (2014-5241)

    Other properties ofW(ej):

    The DTFT of a symmetric rectangular window of length M + 1 is W(esmall x we can approximate sin x x; the error is < 1% for x < 0.25. W(ej) 21 sin0.5(M+ 1).

    The peak value is at = 0 and equals M+ 1;this means that the peak gr

    be M+12

    .

    The minimum value of W(ej ) is approximately equal to the minimuum which is when sin0.5(M + 1) = 1 i.e. = 1.5

    0.5(M+1) = 3

    M+1

    min21 sin0.5(M+ 1) = M+11.5 .

    Passband and Stopband ripple:

    The ripple in W(ej) = sin 0.5(+1)

    sin 0.5 has a period of = 2

    0.5(+1) =

    M

    ripple with this period in both the passband and stopband ofHM+1(ej).

    However the stopband ripple takes the value of HM+1(ej) alternately po

    plot the magnitude response,HM+1(ej ) then this ripple will be full-wave frequency so its period will now be 2

    M+1.

  • 8/10/2019 Handouts for DSP

    91/211

    Window relationships

    6: Window FilterDesign

    nverse DTFT

    Rectangular windowDirichlet Kernel

    Windowrelationships

    Common Windows

    Uncertainty principle

    Order Estimation

    Example Design

    Frequency sampling

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    When you multiply an impulse response by a windoHM+1(e

    j) = 1

    2

    H(ej) W(ej)

    -2 0 20

    0.5

    1

    -2 0 2

    0

    10

    20

    M=20

    0

    0.5

    1

    1

    (a) passband gain w[0]; peak w[0]2 + 0.52

    main

    rectangular window: passband gain = 1; pe

    (b) transitionbandwidth, = width of the matransitionamplitude, H= integral of main

    rectangular window: = 4M+1 , H 1

    (c) stopband gain is an integral over oscillating srect window:

    min H(ej)= 0.09 min(d) features narrower than the main lobe will be

    attenuated

  • 8/10/2019 Handouts for DSP

    92/211

    Common Windows

    6: Window FilterDesign

    nverse DTFT

    Rectangular windowDirichlet Kernel

    Window relationships

    Common WindowsUncertainty principle

    Order Estimation

    Example Design

    Frequency sampling

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    Rectangular: w[n] 1dont use

    Hanning: 0.5 + 0.5c1ck = cos

    2knM+1

    rapid sidelobe decay

    Hamming: 0.54 + 0.46c1best peak sidelobe

    Blackman-Harris3-term:0.42 + 0.5c1+ 0.08c2

    best peak sidelobe

    Kaiser:I0

    1( 2nM)

    2

    I0()

    controls width v sidelobesGood compromise:

    Widthvsidelobevdecay

  • 8/10/2019 Handouts for DSP

    93/211

    Uncertainty principle

    6: Window FilterDesign

    nverse DTFT

    Rectangular windowDirichlet Kernel

    Window relationships

    Common Windows

    Uncertaintyprinciple

    Order Estimation

    Example Design

    Frequency sampling

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    CTFT uncertainty principle: t2|x(t)|2dt

    |x(t)|2dt 1

    2

    2|X

    |XThe first term measures thewidth ofx(t)aro

    It is like if|x(t)|2

    was a zero-mean probThe second term is similarly thewidth ofX(

    A signalcannot be concentrated in both time and fSo a short window cannot have a narrow main

    Proof:Assume

    |x(t)|

    2dt= 1

    |X(j)|

    2d= 2

    Set v(t) = dxdt V(j) =jX(j) [by parts]

    Now

    txdxdt

    dt= 12 tx2t=

    12x

    2dt= 12 [

    So 14 = txdxdt

    dt2 t

    2x2dt dxdt

    2dt

    =

    t2x2dt

    |v(t)|2 dt

    =

    t2x2dt

    12

    =

    t2x2dt

    12

    2 |X(j)|

    2d

    No exact equivalent for DTFT/DFT but a similar e

  • 8/10/2019 Handouts for DSP

    94/211

    [Uncertainty Principle Proof Steps]

    DSP and Digital Filters (2014-5241)

    (1)Suppose v(t) = dxdt

    . Then integrating the CTFT definition by parts w.r.t

    X(j) = x(t)e

    jt

    dt=1j x(t)e

    jt +

    1j

    dx(t)

    dt ej

    (2)Since ddt

    12

    x2

    = xdxdt

    , we can apply integration by parts to get

    tx dx

    dtdt=

    t 1

    2x2

    t=

    dtdt 1

    2x2dt= 1

    2

    x2dt=

    It follows that

    tx dx

    dtdt

    2=

    1

    2

    2= 1

    4which we will use below.

    (3)The Cauchy-Schwarz inequality is that in a complex inner product space|u v|2 (u u) (v v). For the inner-product space of real-valued squa

    this becomes

    u(t)v(t)dt2

    u2(t)dt

    v2(t)dt. We app

    and v(t) = dx(t)dt

    to get

    14

    =

    tx dxdt

    dt

    2 t2x2dt

    dxdt

    2dt

    =

    t2x2dt

    (4)From Parsevals theorem for the CTFT,

    v2

    (t)dt= 12

    |V(j|

    2

    d. Fsubstitute V(j) =jX(j)to obtain

    v2(t)dt= 1

    2

    2 |X(j|2 d

    in (3) gives14

    t2x2dt

    v2(t)dt

    =

    t2x2dt

    12

    2 |X(j|2 d

  • 8/10/2019 Handouts for DSP

    95/211

    Order Estimation

    6: Window FilterDesign

    nverse DTFT

    Rectangular windowDirichlet Kernel

    Window relationships

    Common Windows

    Uncertainty principle

    Order EstimationExample Design

    Frequency sampling

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    Several formulae estimate the required order of a fil

    E.g. for lowpass filterEstimated order is

    M 5.64.3 log

    10()

    21 820 log

    10

    2.2

    Required Mincreases as either thetransition width, 2 1, or the gain

    tolerances and get smaller.Only approximate.

    Example:Transition band: f1 = 1.8 kHz, f2 = 2.0 kHz,

    1 = 2f1fs

    = 0.943, 2 = 2f2fs

    = 1.0

    Ripple: 20 log10(1 + ) = 0.1 dB, 20 log10 == 10

    0.1

    20 1 = 0.0116, = 1035

    20 =

    M 5.64.3 log

    10(2104)1.0470.943 =

    10.250.105 = 98 o

  • 8/10/2019 Handouts for DSP

    96/211

    Example Design

    6: Window FilterDesign

    nverse DTFT

    Rectangular windowDirichlet Kernel

    Window relationships

    Common Windows

    Uncertainty principle

    Order Estimation

    Example DesignFrequency sampling

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    Specifications:Bandpass: 1 = 0.5, 2 = 1Transition bandwidth: = 0.1Ripple: == 0.02

    20 log10 = 34 dB20 log10(1 + ) = 0.17 dB

    Order:

    M

    5.64.3 log10()

    21 = 92Ideal Impulse Response:

    Difference of two lowpass filtersh[n] = sin2n

    n sin1n

    n

    Kaiser Window: = 2.5

    0

    M=92

    0

    0

    -

    -

    -

  • 8/10/2019 Handouts for DSP

    97/211

    Frequency sampling

    6: Window FilterDesign

    nverse DTFT

    Rectangular windowDirichlet Kernel

    Window relationships

    Common Windows

    Uncertainty principle

    Order Estimation

    Example Design

    Frequencysampling

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    Take M+ 1 uniform samples ofH(ej); take IDFT

    Advantage:exact match at sample points

    Disadvantage:poor intermediate approximation if spectrum is

    Solutions:

    (1) make the filter transitions smooth over (2) oversample and do least squares fit (cant u(3) use non-uniform points with more near tran

    -2 0 20

    0.5

    1M+1=93

    0 1

    0

    0.5

    1

  • 8/10/2019 Handouts for DSP

    98/211

    Summary

    6: Window FilterDesign

    nverse DTFT

    Rectangular windowDirichlet Kernel

    Window relationships

    Common Windows

    Uncertainty principle

    Order Estimation

    Example Design

    Frequency sampling

    SummaryMATLAB routines

    DSP and Digital Filters (2014-5241)

    Make an FIR filter by windowing the IDTFT of idIdeal lowpass has h[n] = sin0n

    nAdd/subtract lowpass filters to make any response

    Ideal response is with window DTFTRectangular window (Dirichlet kernel) has

    and is always a bad idea

    Hamming, Blackman-Harris are good; KaUncertainty principle: cannot be concentrated in

    Frequency sampling: IDFT of uniform frequency

    For further details see Mitra: 7, 10.

  • 8/10/2019 Handouts for DSP

    99/211

    MATLAB routines

    6: Window FilterDesign

    nverse DTFT

    Rectangular windowDirichlet Kernel

    Window relationships

    Common Windows

    Uncertainty principle

    Order Estimation

    Example Design

    Frequency sampling

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    diric(x,n) Dirichlet kernel: sin0.5sin0.

    hanninghammingkaiser

    Window functions(Note periodic optio

    kaiserord Estimate required filter orde

  • 8/10/2019 Handouts for DSP

    100/211

    7: Optimal FIR filt

    7: Optimal FIRfilters

    Optimal Filters

    Alternation TheoremChebyshevPolynomials

    Maximal ErrorLocationsRemez ExchangeAlgorithm

    Determine Polynomial

    Example Design

    FIR Pros and Cons

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

  • 8/10/2019 Handouts for DSP

    101/211

    Optimal Filters

    7: Optimal FIR filters

    Optimal FiltersAlternation Theorem

    ChebyshevPolynomials

    Maximal ErrorLocationsRemez ExchangeAlgorithm

    Determine Polynomial

    Example Design

    FIR Pros and Cons

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    We restrict ourselves to zero-phase filters of odd lenaround h[0], i.e. h[n] =h[n].

    H() =H(ej) =M

    2

    M2

    h[n]ejn=h[0] + 2

    H() is real but not necessarily positive (unlik

    Weighted error: e() =s()

    H()d()

    whereChoose s() to control the error variation with

    Example: lowpass filter

    d() =

    1 01

    0 2

    s() = 1 01

    1 2

    e() =1 when H() lies at the edge of the spe

    Minimax criterion: h[n] = arg minh[n]max|e()|:

  • 8/10/2019 Handouts for DSP

    102/211

    Alternation Theorem

    7: Optimal FIR filters

    Optimal Filters

    Alternation

    TheoremChebyshevPolynomials

    Maximal ErrorLocationsRemez ExchangeAlgorithm

    Determine Polynomial

    Example Design

    FIR Pros and Cons

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    Want to find the best fit line: with the smallest max

    Best fit line always attains themaximal error three times withalternate signs

    2 42

    4

    6

    8

    Proof:Assume the first maximal deviation from the line is

    There must be an equally large positive deviation; odownwards to reduce the maximal deviation.This must be followed by another maximal negativecan rotate the line and reduce the deviations.

    Alternation Theorem:A polynomial fit of degree n to a bounded set of po

    only if it attains its maximal error at n+ 2 points wThere may be additional maximal error points.Fitting to a continuous function is the same as to apoints.

  • 8/10/2019 Handouts for DSP

    103/211

    Chebyshev Polynomials

    7: Optimal FIR filters

    Optimal Filters

    Alternation Theorem

    ChebyshevPolynomialsMaximal ErrorLocationsRemez ExchangeAlgorithm

    Determine Polynomial

    Example Design

    FIR Pros and Cons

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    H() =H(ej) =h[0] + 2M2

    1 h[n]cos n

    But cos n=Tn(cos ): Chebyshev polynomialof

    cos2= 2 cos2 1 = T2(cos )cos3= 4 cos3 3 cos = T3(cos )

    Recurrence Relation:Tn+1(x) = 2xTn(x) Tn1(x)with T0(x) = 1

    Proof: cos(n+) + cos (n) = 2 cos

    So H() is an M2 order polynomial in cos : altern

    Example: Low-pass filter of length 5 (M= 4)

    0 0.5 1 1.5 2 2.5 3 3.5

    0

    0.2

    0.4

    0.6

    0.8

    1

    1.2

    1.4

    |g|

    M=4

    0 0.5 1 1.5 2 2.5 3

    -15

    -10

    -5

    0

    |g|(dB)

    M=4

    -1

    0

    0.5

    1

    g

  • 8/10/2019 Handouts for DSP

    104/211

    Maximal Error Locations

    7: Optimal FIR filters

    Optimal Filters

    Alternation Theorem

    ChebyshevPolynomials

    Maximal ErrorLocations

    Remez ExchangeAlgorithm

    Determine Polynomial

    Example Design

    FIR Pros and Cons

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    Maximal error locations occur either at bandedges or when dH

    d

    = 0

    H() =h[0] + 2M

    2

    1 h[n]cos n=P(cos )

    where P(x)is a polynomial of order M2 .

    |H|

    dH

    d

    =P(cos )sin

    = 0 at = 0, and at most M2 1 zeros of p

    With two bands, we have at most M2 + 3 maxim

    We require M2 + 2 of alternating signs for the optim

    Only three possibilitiesexist (try them all):

    (a) = 0 + two band edges + M2 1 zeros ofP(b) = + two band edges + M2 1 zeros ofP

    (c) ={0 and } + two band edges + M2 2 z

  • 8/10/2019 Handouts for DSP

    105/211

    Remez Exchange Algorithm

    7: Optimal FIR filters

    Optimal Filters

    Alternation Theorem

    ChebyshevPolynomials

    Maximal ErrorLocations

    Remez ExchangeAlgorithm

    Determine Polynomial

    Example Design

    FIR Pros and Cons

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    1. Guessthe positions of the M2 + 2 maximal error alternating signs to the errors (e.g. choose evenl

    2. Determinethe error magnitude, , and the M2 + the polynomial that passes through the maximal

    3. Find the local maximaof the error function by eve() =s()

    H() d()

    on a dense set of

    4. Update the maximal error frequenciesto be an athe local maxima + band edges + {0 and/or }

    If maximum error is > , go back to step 2. (t

    5. Evaluate H() on M+ 1 evenly spaced and d

    0 0.5 1 1.5 2 2.5 3

    -0.5

    0

    0.5

    1

    1.5

    |g|

    M = 4Iteration 1

    0 0.5 1 1.5 2 2.5 3

    0

    0.5

    1

    |g|

    M = 4Iteration 2

    0

    0

    0.5

    1

    |g|

  • 8/10/2019 Handouts for DSP

    106/211

    Determine Polynomial

    7: Optimal FIR filters

    Optimal Filters

    Alternation Theorem

    ChebyshevPolynomials

    Maximal ErrorLocationsRemez ExchangeAlgorithm

    DeterminePolynomial

    Example Design

    FIR Pros and Cons

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    For each extremal frequency, i for1i M2 + 2

    d(i) =H(i) + (1)i

    s(i) =h[0] + 2

    M2

    n=1h[n]co

    Method 1: (Computation time M3)Solve M2 + 2 equations in

    M2 + 2 unknowns for h

    In step 3, evaluate H() =h[0] + 2M2

    n=1h[n]co

    Method 2: Dont calculate h[n] explicitly (ComputaMultiply equations by ci =

    j=i

    1cosicosj

    andM2+2

    i=1 ci

    h[0] + 2

    M2

    n=1h[n]cos n+ (1)is(i)

    =

    All terms involving h[n]sum to zero leaving

    M2 +2i=1

    (1)ici

    s(i) = M2 +2

    i=1 c

    id(

    i)

    Solve for thencalculate the H(i)then useLag

    H() =P(cos ) =M

    2+2

    i=1 H(i)

    j=icoscosi

    M2 + 1

    -polynomial going through all the H(

  • 8/10/2019 Handouts for DSP

    107/211

    Example Design

    7: Optimal FIR filters

    Optimal Filters

    Alternation Theorem

    ChebyshevPolynomials

    Maximal ErrorLocationsRemez ExchangeAlgorithm

    Determine Polynomial

    Example DesignFIR Pros and Cons

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    Filter Specifications:Bandpass = [0.5, 1], Transition widths: Stopband Attenuation: 25 dB and 15 dBPassband Ripple: 0.3 dB

    Determinegain tolerancesfor each band:25 dB= 0.056, 0.3 dB= 1 0.034, 15 d

    Predicted order: M= 36M2 + 2 extremal frequencies are distributed bet

    Filter meets specs ; clearer on a decibel scaleMost zeros are on the unit circle + threereciprocal

    Reciprocal pairs give a linear phase shift

    0 0.5 1 1.5 2 2.5 30

    0.2

    0.4

    0.6

    0.8

    1

    |H|

    M=36

    0 0.5 1 1.5 2 2.5 3

    -30

    -25

    -20

    -15

    -10

    -5

    0

    |H|(d

    B)

    M=36

    -1

    -0.5

    0

    0.5

    1

  • 8/10/2019 Handouts for DSP

    108/211

    FIR Pros and Cons

    7: Optimal FIR filters

    Optimal Filters

    Alternation Theorem

    ChebyshevPolynomials

    Maximal ErrorLocationsRemez ExchangeAlgorithm

    Determine Polynomial

    Example Design

    FIR Pros and ConsSummary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    Can havelinear phase no envelope distortion, all frequencies ha symmetric or antisymmetric: h[n] =h[ antisymmetric filters haveH(ej0) =H(e symmetry means you only need M2 + 1 m

    to implement the filter.

    Alwaysstable

    Low coefficient sensitivity

    Optimal design methodfast and robust

    Normally needshigher orderthan an IIR filter Filter orderM dBatten3.5 where is th

    Filtering complexityMfs

    dBatten

    3.5 f2s for a given specification in unscaled

  • 8/10/2019 Handouts for DSP

    109/211

  • 8/10/2019 Handouts for DSP

    110/211

    MATLAB routines

    7: Optimal FIR filters

    Optimal Filters

    Alternation Theorem

    ChebyshevPolynomials

    Maximal ErrorLocationsRemez ExchangeAlgorithm

    Determine Polynomial

    Example Design

    FIR Pros and Cons

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    firpm optimal FIR filter design

    firpmord estimate require order for fircfirpm arbitrary-response filter desigremez [obsolete] optimal FIR filter de

  • 8/10/2019 Handouts for DSP

    111/211

    8: IIR Filter Transform

    8: IIR FilterTransformations

    Continuous TimeFilters

    Bilinear Mapping

    Continuous TimeFiltersMapping Poles andZerosSpectralTransformationsConstantinidesTransformations

    mpulse Invariance

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

  • 8/10/2019 Handouts for DSP

    112/211

    Continuous Time Filters

    8: IIR FilterTransformations

    Continuous TimeFilters

    Bilinear Mapping

    Continuous TimeFiltersMapping Poles andZerosSpectralTransformationsConstantinidesTransformations

    mpulse Invariance

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    Classical continuous-time filters optimize tradeoff:passband ripple v stopband ripple v transition widthThere are explicit formulae for pole/zero positions.

    Butterworth:G2() = H(j)2 = 11+2N Monotonic

    G() = 1 12

    2N + 384N +

    Maximally flat: 2N 1 derivatives are zeroChebyshev:G2() = 1

    1+2T2N()

    where polynomial TN(cos x) = cos N x passband equiripple + very flat at

    Inverse Chebyshev:G2() = 1

    1+(2

    T2N(

    1

    ))1

    stopband equiripple + very flat at0

    Elliptic: [no nice formula] Very steep + equiripple in pass and stop band

  • 8/10/2019 Handouts for DSP

    113/211

    Bilinear Mapping

    8: IIR FilterTransformationsContinuous TimeFilters

    Bilinear MappingContinuous TimeFiltersMapping Poles andZerosSpectralTransformationsConstantinidesTransformations

    mpulse Invariance

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    Change variable: z= +ss s=

    z1z+1 : a one-to-o

    axis (s) axis (z)

    axis (s) Unit circle (z)

    Proof: z=ejs= ej1ej+1 =

    ej2ej

    2

    ej2+ej

    2

    =

    Left half plane(s)inside of unit circle (z)

    Proof: s=x +jy |z|2 = |(+x)+jy|2

    |(x)jy|2

    = 2+2x+x2+y

    22x+x2+y

    x

  • 8/10/2019 Handouts for DSP

    114/211

    Continuous Time Filters

    8: IIR FilterTransformationsContinuous TimeFilters

    Bilinear Mapping

    Continuous TimeFilters

    Mapping Poles andZerosSpectralTransformationsConstantinidesTransformations

    mpulse Invariance

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    Take

    H(s) = 1

    s2+0.2s+4 and choose = 1

    Substitute: s= z1z+1 [extra zeros at z=

    H(z) = 1( z1z+1 )

    2+0.2 z1

    z+1+4

    = (z+1)2

    (z1)2+0.2(z1)(z+1)+4(z+1)2

    = z2+2z+15.2z2+6z+4.8 = 0.19

    1+2z1+z2

    1+1.15z1+0.92z2

    Frequency response is identical(both magnitude anphase) but with a distorted frequency axis:

    Frequency mapping: = 2 tan1

    =

    2 3 4 5

    = 1.6 2.2 2.5 2.65 2.75 Choosing: Set = 0

    tan 120

    to map 0 0

    Set = 2fs= 2T

    to map low frequen

  • 8/10/2019 Handouts for DSP

    115/211

    Mapping Poles and Zeros

    8: IIR FilterTransformationsContinuous TimeFilters

    Bilinear Mapping

    Continuous TimeFilters

    Mapping Poles andZeros

    SpectralTransformationsConstantinidesTransformations

    mpulse Invariance

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    Alternative method:

    H(s) = 1

    s2+0.2s+4

    Find the poles and zeros: ps= 0.1 2jMap using z =1+s1s pz = 0.58 0.77j

    After the transformation we will always end up withthesame number of poles as zeros:

    Add extra poles or zeros at z = 1

    H(z) =g (1+z1

    )

    2

    (1+(0.580.77j)z1)(1+(0.58+0.77j)z1)

    =g 1+2z1+z2

    1+1.15z1+0.92z2

    Choose overallscale factor, g,to give the same gainat any convenient pair of mapped frequencies:

    At0 = 0 s0 = 0 H(s0)

    = 0.25

    0 = 2 tan1 0 = 0 z0 =ej0 = 1

    |H(z0)| =g 43.08 = 0.25 g= 0.19

    H(z) = 0.19 1+2z1+z2

    1+1.15z1+0.92z2

  • 8/10/2019 Handouts for DSP

    116/211

    Spectral Transformations

    8: IIR FilterTransformationsContinuous TimeFilters

    Bilinear Mapping

    Continuous TimeFiltersMapping Poles andZeros

    SpectralTransformations

    ConstantinidesTransformations

    mpulse Invariance

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    We can transform the z-plane to change the cutofffrequency by substituting

    z= z1z z= z+1+z

    Frequency Mapping:

    Ifz =ej, then z =z 1+z1

    1+z has modulus 1since the numerator and denominator are

    complex conjugates.

    Hence theunit circle is preserved. ej = e

    j+1+ej

    Some algebra gives: tan 2 =1+1

    tan 2

    Equivalent to:z s= z1

    z+1 s= 11+s z=

    1+s1s

    Lowpass Filter example:Inverse Chebyshev

    0 = 2 = 1.57

    =0.6 0 = 0.49

  • 8/10/2019 Handouts for DSP

    117/211

  • 8/10/2019 Handouts for DSP

    118/211

    Impulse Invariance

    8: IIR FilterTransformationsContinuous TimeFilters

    Bilinear Mapping

    Continuous TimeFiltersMapping Poles andZerosSpectralTransformationsConstantinidesTransformations

    Impulse InvarianceSummary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    Bilinear transform works well for a lowpass filter bucompression of the frequency distorts any other resp

    Alternative method:H(s) L1 h(t) sample h[n] ZExpressH(s)as a sum of partial fractionsH(s) Impulse response is h(t) =u(t)

    Ni=1 gie

    pit

    Digital filter H(z) =N

    i=1gi

    1epiTz1has identic

    Poles ofH(z) arepi=epiT

    (where T = 1fs is sa

    Zeros do not map in a simple way

    Properties: Impulse response correct. No distort Frequency response is aliased.

    Example: Standard telephone filter - 300 to 3400 H

    0 5 10 15 20 250

    0.5

    1

    Frequency (krad/s)

    |H|

    Analog Filter

    0 0.5 1 1.5 2 2.5 30

    0.5

    1

    (rad/sample)

    |H|

    Bilinear (fs= 8 kHz)

    Matched at 3.4 kHz

    0 0.5 1 1.5

    0.2

    0.4

    0.6

    0.8

    1

    (rad/s

    |H|

    Impulse Invarian

  • 8/10/2019 Handouts for DSP

    119/211

    Summary

    8: IIR FilterTransformationsContinuous TimeFilters

    Bilinear Mapping

    Continuous TimeFiltersMapping Poles andZerosSpectralTransformationsConstantinidesTransformations

    mpulse Invariance

    SummaryMATLAB routines

    DSP and Digital Filters (2014-5241)

    Classical filtershave optimal tradeoffs in cont Order transition widthpass ripple Monotonic passband and/or stopband

    Bilinear mapping Exact preservation of frequency response non-linear frequency axis distortion can choose to map 0 0 for one s

    Spectral transformations lowpasslowpass, highpass, bandpass o bandpass and bandstop double the filter

    Impulse Invariance Aliassing distortion of frequency response preserves frequency axis and impulse resp

    For furt

  • 8/10/2019 Handouts for DSP

    120/211

    MATLAB routines

    8: IIR FilterTransformationsContinuous TimeFilters

    Bilinear Mapping

    Continuous TimeFiltersMapping Poles andZerosSpectralTransformationsConstantinidesTransformations

    mpulse Invariance

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-5241)

    bilinear Bilinear mapping

    impinvar Impulse invariancebutterbutterord

    Analog or digitalButterworth filter

    cheby1cheby1ord

    Analog or digitalChebyshev filter

    cheby2cheby2ord

    Analog or digitalInverse Chebyshev filter

    ellipellipord

    Analog or digitalElliptic filter

  • 8/10/2019 Handouts for DSP

    121/211

    9: Optimal IIR Des

    9: Optimal IIRDesign

    Error choices

    Linear Least SquaresFrequency Sampling

    terative Solution

    Newton-Raphson

    Magnitude-onlySpecification

    Hilbert RelationsMagnitude PhaseRelation

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-4123)

  • 8/10/2019 Handouts for DSP

    122/211

    Error choices

    9: Optimal IIRDesign

    Error choicesLinear Least SquaresFrequency Sampling

    terative Solution

    Newton-Raphson

    Magnitude-onlySpecification

    Hilbert RelationsMagnitude PhaseRelation

    Summary

    MATLAB routines

    DSP and Digital Filters (2014-4123)

    We want to find a filter H(ej) = B(ej)

    A(ej) that appr

    responseD(). Assume A is order N and B is ordTwo possible error measures:

    Solution Error: ES() =WS()B(ej)A(ej) D(

    Equation Error: EE() =WE() B(ej) D

    We may know D()completely or else only |D

    We minimize

    |E()|p

    d

    where p= 2 (least squares)

    Weight functions W() are chos