Chap6_Frequency Response of FIR Filters

Embed Size (px)

Citation preview

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    1/32

    ECE 2610 Signal and Systems 61

    Frequency Responseof FIR FiltersThis chapter continues the study of FIR filters from Chapter 5,

    but the emphasis isfrequency response, which relates to how the

    filter responds to an input of the form

    .

    A fundamental result we shall soon see, is that the frequency

    response and impulse response are related through an operation

    known as the Fourier transform. The Fourier transform itself is

    not however formally studied in this chapter.

    Sinusoidal Response of FIR Systems

    Consider an FIR filter when the input is a complex sinusoid

    of the form

    , (6.1)

    where it could be that was obtained by sampling the

    complex sinusoid and

    From the difference equation for an tap FIR filter,

    (6.2)

    x n ej0n n =

    x n Aejej0n n =

    x n x t Aeje

    j0t= 0 0Ts=

    M 1+

    y n bk x n k k 0=

    M

    bkAej

    ej0 n k

    k 0=

    M

    = =

    Chapter

    6

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    2/32

    Sinusoidal Response of FIR Systems

    ECE 2610 Signals and Systems 62

    (6.3)

    where we have defined for arbitrary

    (6.4)

    to be thefrequency response of the FIR filter

    Note: The notation is used rather than say , to

    be consistent with the z-transform which will defined in

    Chapter 7, and to emphasize the fact that the frequency

    response is periodic, with period (more on this later)

    Note: , where sine and cosine are

    both functions

    Returning to (6.2), the implication is that when the input is a

    complex exponential at frequency , the output is also a

    complex exponential at frequency

    The complex amplitude (magnitude and phase) of the input is

    changed as a result of passing through the system

    The frequency response at multiplies the input ampli-tude to produce the output

    It is not true in general that , but

    only for the special case of a complex sinusoid

    applied starting at

    y n Aej

    ej0n

    bkej 0k

    k 0=

    M

    =

    Aejej0n

    H ej

    0 n =

    H ej bke

    j k

    k 0=

    M

    =

    H ej H

    2

    ej j sin+cos=mod 2

    00

    0

    n H ej0 x n =x n

    http://-/?-http://-/?-
  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    3/32

    Sinusoidal Response of FIR Systems

    ECE 2610 Signals and Systems 63

    The frequency response is a complex function of that is

    generally viewed in either polar or rectangular form

    (6.5)

    The polar or magnitude and phase form is perhaps the

    most common

    The polar form offers the following interpretation of in

    terms of , when the input is a complex sinusoid

    (6.6)

    Here we see that the input amplitude is multiplied by the

    frequency response amplitude, and the input phase has

    added to it the frequency response phase The output amplitude expression means that is

    also termed the gain of an LTI system

    Example:

    The frequency response of this FIR filter is

    H e

    j

    H ej

    e j H e

    j

    =Re H e

    j jIm H ej +=

    n x n

    y n H ej e j H ej

    Aej

    ejn

    =

    H ej

    Ae j H e

    j + e

    jn=

    H ej

    bk 1 1 3 1 1 =

    H ej

    bke j

    k

    k 0=

    4

    =

    1 ej

    3ej 2

    ej 3

    ej 4

    + + + +=

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    4/32

    Sinusoidal Response of FIR Systems

    ECE 2610 Signals and Systems 64

    We have used the inverse Euler formula for cosine twice

    For this particular filter we have that

    Why?

    Use MATLAB to plot the magnitude and phase response

    >> w = 0:2*pi/200:2*pi;

    >> H = exp(-j*2*w).*(3 + 2*cos(w) + 2*cos(2*w));

    >> subplot(211)

    >> plot(w,abs(H))

    >> axis([0 2*pi 0 8])

    >> grid

    >> ylabel('Magnitude')>> subplot(212)

    >> plot(w,angle(H))

    >> axis([0 2*pi -pi pi])

    >> grid

    >> ylabel('Phase (rad)')

    H ej e j2

    e

    j2e

    j3 e

    je

    j2+ + + + =

    ej2

    2 2 2 3+cos+cos =

    H ej 3 2 cos 2 2 cos+ +=

    H ej 2=

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    5/32

    Sinusoidal Response of FIR Systems

    ECE 2610 Signals and Systems 65

    >> xlabel('hat(\omega) (rad)')

    Example: Find for Input

    The input frequency is rad, the amplitude is 5, and

    the phase is

    Assuming is input to the 4-tap FIR filter in the previous

    example, the filter output is

    The amplitude response or gain at is =3.248; why?

    0 1 2 3 4 5 60

    2

    4

    6

    8

    Magnitude

    0 1 2 3 4 5 6

    2

    0

    2

    Phase(rad)

    hat() (rad)

    2

    2

    3.248

    -2

    y n x n 5ej 1 n =

    0 1=

    0=x n

    y n 3 2 1 cos 2 2 1 cos+ + ej 1 2

    5ej 1 n

    =

    16.2415ej2

    ejn

    =

    0 1= H ej1

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    6/32

    Superposition and the Frequency Response

    ECE 2610 Signals and Systems 66

    Superposition and the Frequency Response

    We can use the linearity of the FIR filter to compute the out-

    put to a sum of sinusoids input signal

    As a special case we first consider a single real sinusoid

    (6.7)

    Using Eulers formula we expand (6.7)

    (6.8)

    The filter output due to each complex sinusoid is known from

    (6.3), so now using superposition we can write

    (6.9)

    We can simplify this result to a nice compact form, if we

    make the assumption that the FIR filter has real coefficients Special Result: It will be shown in a later section of this

    chapter that an FIR filter with real coefficients has conjugate

    symmetry

    (6.10)

    What does this mean?

    x n A 0n + cos=

    x n A2---e

    j 0n + A

    2---e

    j 0n + +=

    n A2---H e

    j0 ej 0n + A2---H e

    j 0 e j 0n + +=

    H ej H* e

    j =

    H ej Re H ej jIm H ej =

    H ej H ej =

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    7/32

    Superposition and the Frequency Response

    ECE 2610 Signals and Systems 67

    We now use (6.10) to simplify (6.9)

    (6.11)

    We see that when a real sinusoid passes through an LTI sys-

    tem, such as an FIR filter (having real coefficients), the out-

    put is also a real sinusoid which has picked up the magnitude

    and phase of the system at

    The generalization (sum of sinusoids) of this result is when

    , (6.12)

    then the corresponding LTI system output is

    (6.13)

    y n A

    2---H e

    j0 ej 0n + A

    2---H* e

    j0 e j 0n +

    +=

    A H ej0 =

    e

    j 0n H ej + +

    ej 0n H e

    j + + +

    2-------------------------------------------------------------------------------------------------

    y n A H ej0 0

    n H ej0 + + cos=

    0=

    x n X0 Xk kn Xk+ cosk 1=

    N

    +=

    y n X0H ej0 =

    Xk H ejk

    kn Xk H ejk

    + + cosk 1=

    N

    +

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    8/32

    Superposition and the Frequency Response

    ECE 2610 Signals and Systems 68

    Example: Three Inputs with

    The input is

    The frequency response is

    The input frequencies are

    Thus

    >> w = 0:pi/200:pi;

    >> H = 1 - exp(-j*w) + exp(-j*2*w);>> subplot(211)

    >> plot(w,abs(H))

    >> grid

    >> hold

    >> plot([pi/4 pi/4],[0 3],'r')

    bk 1 1 1 =

    x n 10 4 4---n

    8---+ cos 3 3

    ---n 4--- cos+ +=

    H ej 1 e j e

    j2+=

    ej

    1 2 cos+ =

    k 0 4 3 =

    H ej0 e j0

    1 2 0 cos+ 1= =

    H ej 4 e j 4 1 2 4 cos+ 0.4142e

    j 4= =

    H ej 3 e j 3

    1 2 3 cos+ 0= =

    n 10 1 4 0.4142 4---n

    8---

    4---+

    cos+=

    10= 1.65694---n

    8---

    cos+

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    9/32

    Superposition and the Frequency Response

    ECE 2610 Signals and Systems 69

    >> plot([pi/3 pi/3],[0 3],'r')

    >> ylabel('Magnitude')

    >> subplot(212)

    >> plot(w,angle(H))

    >> grid>> hold

    >> plot([pi/4 pi/4],[-2 3],'r')

    >> ylabel('Phase (rad)')

    >> xlabel('Digital Frequency \omega')

    We have used frequency domain analysis to complete this

    example

    We could also perform a time domain analysis using say

    MATLABs filter function (more on this in the next section)

    0 0.5 1 1.5 2 2.5 3 3.50

    0.5

    1

    1.5

    2

    2.5

    3

    Magnitude

    0 0.5 1 1.5 2 2.5 3 3.52

    1

    0

    1

    2

    3

    Digital Frequency

    Phase(rad)

    H ej

    4---

    3---

    4---

    0.4142 0

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    10/32

    Steady-State and Transient Response

    ECE 2610 Signals and Systems 610

    Steady-State and Transient Response

    The frequency response definition relies on the fact that the

    support interval for the complex sinusoid input is

    In a computer simulation or in a real-time signal processing

    application, it is not practical to consider input signals which

    begin at

    Consider an input that begins at using the unit step

    function to turn on the input

    (6.14)

    where and

    (6.15)

    For an LTI FIR system, the convolution sum formula yields

    (6.16)

    n 0=

    x n Xejnu n =

    Aej

    =

    u n 1, n 00, otherwise

    n bkXej n k

    u n k k 0=

    M

    =

    h k

    k0 M

    kn 0

    . . .

    u n k

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    11/32

    Steady-State and Transient Response

    ECE 2610 Signals and Systems 611

    The sum of(6.16) is composed of three cases

    (6.17)

    When the input is not present, so the output is zero

    When the input has partially engaged the filter and

    the output produced is the transient response

    When , the output is in steady-state, since the input has

    fully engaged the filter

    Note that the steady-state response is also equivalent to

    saying

    (6.18)

    Note also that the steady-state output assumes that the

    input is always for

    Example: Revisit Three Inputs with

    The frequency domain analysis used in the previous example

    obtained just the steady-state portion of the output

    We can evaluate the convolution sum or use MATLABs filter

    function to obtain a solution of the form described in (6.17)

    n

    0, n 0

    bkejk

    k 0=

    n

    Xejn, 0 n M

    bkejk

    k 0=

    M

    Xejn

    , n M

    =

    n 0

    0 n M

    n M

    n H ej Xej n M=

    Xejn

    n 0

    bk 1 1 1 =

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    12/32

    Steady-State and Transient Response

    ECE 2610 Signals and Systems 612

    >> n = -5:20;

    >> x = (10 + 4*cos(pi/4*n+pi/8) + ...

    3*cos(pi/3*n-pi/4)).*ustep(n,0);

    >> y = filter([1 -1 1],1,x);

    >> subplot(211)>> stem(n,x,'filled')

    >> grid

    >> ylabel('x[n]')

    >> subplot(212)

    >> stem(n,y,'filled')

    >> hold

    Current plot released

    >> stem(n,y,'filled')>> grid

    >> ylabel('y[n]')

    >> xlabel('Sample Index n')

    5 0 5 10 15 200

    5

    10

    15

    20

    x[n]

    5 0 5 10 15 205

    0

    5

    10

    15

    20

    y[n]

    Sample Index n

    TransientInterval

    Steady-state

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    13/32

    Steady-State and Transient Response

    ECE 2610 Signals and Systems 613

    The function ustep() is defined as:

    function x = ustep(n,n0)

    % function x = ustep(n,n0)

    %

    % Generate a time shifted unit step sequence

    x = zeros(size(n));

    i_n0 = find(n >= n0);

    x(i_n0) = ones(size(i_n0));

    If we consider just the steady-state portion of the output we

    should be able to discern the same output as obtained from

    the frequency domain analysis of the previous example

    The measurements above agree with the earlier example

    5 10 15 208

    8.5

    9

    9.5

    10

    10.5

    11

    11.5

    12

    y[n]

    Sample Index n

    2 1.6568 3.3138=

    x[n] cos() peak

    y[n] peaklag 1/2sample =/8

    DC = 10

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    14/32

    Properties of the Frequency Response

    ECE 2610 Signals and Systems 614

    Properties of the Frequency Response

    Relation to Impulse Response and Difference Equation

    In the definition of the frequency response, , for anFIR filter, the coefficients were utilized

    Similarly given the frequency response, the impulse response

    can be found

    In Chapter 5 we saw that the impulse response and difference

    equation are directly related, so in summary given one the

    other two are easy to obtain

    Example:

    Given say

    we immediately see that

    The difference equation is

    The frequency response is

    H ej

    bk

    Time Domain Frequency Domain

    h n h k n k k 0=

    M

    = H ej

    h k ejk

    k 0=

    M

    =

    h n H ej

    h n 2 n 3 n 1 2 n 2 +=

    bk 2 3 2 =

    y n 2x n 3x n 1 2x n 2 +=

    H ej 2 3e j 2e j 2+=

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    15/32

    Properties of the Frequency Response

    ECE 2610 Signals and Systems 615

    Example: Difference Equation from

    Suppose that

    We immediately can write that

    and

    It could have been that

    started in this form

    Example:

    We need to convert the sine form back to complex exponen-

    tials

    The impulse response is thus?

    H ej

    H ej 1 4e j 2 4e j 4+ +=

    h n n 4 n 2 4 n 4 + +=

    n x n 4x n 2 4x n 4 + +=

    H ej

    1 8ej2 e

    j2e

    j2+

    2-----------------------------

    +=

    1 8ej2

    2 cos+=

    H ej 2j 2 e j 2sin=

    H ej 2je j 2 e

    j 2e

    j 2

    2j----------------------------------

    =

    1 ej

    =

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    16/32

    Properties of the Frequency Response

    ECE 2610 Signals and Systems 616

    The difference equation is?

    Periodicity of

    For any discrete-time LTI system, the frequency response is

    periodic, that is

    (6.19)

    The proof for FIR filters follows

    (6.20)

    This result is consistent with the fact that sinusoidal signals

    are insensitive to frequency shifts, i.e.,

    In summary, the frequency response is unique on at most a

    interval, say in particular the interval

    Conjugate Symmetry

    The frequency response is in general a complex

    quantity, in most cases obeys certain symmetry properties

    H ej

    H ej 2+ H e

    j

    H ej 2+

    bkej 2+

    k 0=

    M

    =

    bkej

    ej2

    k 0=

    M

    H ej

    ==

    1

    2

    x n Xej 2+ n

    Xejn

    ej2n

    Xejn

    = = =

    2

    H ej

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    17/32

    Properties of the Frequency Response

    ECE 2610 Signals and Systems 617

    In particular if the coefficients of a digital filter are real, that

    is or , then

    (6.21)

    proof

    (6.22)

    A consequence of conjugate symmetry is that

    (6.23)

    We say that the magnitude response is an even function of

    and the phase is an odd function of

    It also follows that

    (6.24)

    We say that the real part response is an even function ofand the imaginary part is an odd function of

    When plotting the frequency response we can use the above

    symmetry to just plot over the interval

    bk bk*= h k h* k =

    Conjugate Symmetry: H ej H* ej =

    H* ej bke

    jk

    k 0=

    M

    *

    bk*

    ejk

    k 0=

    M

    = =

    bkej k

    k 0=

    M

    H e

    j ==

    H ej

    H ej

    =

    H ej H ej

    =

    Re H ej

    Re H ej

    =

    Im H ej Im H ej =

    0

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    18/32

    Graphical Representation of the Frequency Response

    ECE 2610 Signals and Systems 618

    Graphical Representation of the Frequency

    Response

    A useful MATLAB function for plotting the frequencyresponse of any discrete-time (digital) filter is freqz()

    The interface to freqz() is similar to filter() in that a

    and b vectors are again required

    Recall that the b vector holds the FIR coefficients

    and for FIR filters we set a = 1.>> help freqz

    FREQZ Digital filter frequency response.

    [H,W] = FREQZ(B,A,N) returns the N-point complex frequency response

    vector H and the N-point frequency vector W in radians/sample of

    the filter:

    jw -jw -jmw

    jw B(e) b(1) + b(2)e + .... + b(m+1)e

    H(e) = ---- = ------------------------------------

    jw -jw -jnw

    A(e) a(1) + a(2)e + .... + a(n+1)e

    given numerator and denominator coefficients in vectors B and A. The

    frequency response is evaluated at N points equally spaced around the

    upper half of the unit circle. If N isn't specified, it defaults to512.

    [H,W] = FREQZ(B,A,N,'whole') uses N points around the whole unit circle.

    H = FREQZ(B,A,W) returns the frequency response at frequencies

    designated in vector W, in radians/sample (normally between 0 and pi).

    [H,F] = FREQZ(B,A,N,Fs) and [H,F] = FREQZ(B,A,N,'whole',Fs) return

    frequency vector F (in Hz), where Fs is the sampling frequency (in Hz).

    H = FREQZ(B,A,F,Fs) returns the complex frequency response at the

    frequencies designated in vector F (in Hz), where Fs is the samplingfrequency (in Hz).

    FREQZ(B,A,...) with no output arguments plots the magnitude and

    unwrapped phase of the filter in the current figure window.

    See also filter, fft, invfreqz, fvtool, and freqs.

    bk

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    19/32

    Graphical Representation of the Frequency Response

    ECE 2610 Signals and Systems 619

    Example: Delay System

    This filter contains one coefficient, , so

    >> [H,w] = freqz([0 0 0 0 1],1);

    >> subplot(211)

    >> plot(w,abs(H))

    >> axis([0 pi 0 1.2]); grid

    >> ylabel('Magniude Response')

    >> subplot(212)

    >> plot(w,angle(H))>> axis([0 pi -pi pi]); grid

    >> ylabel('Phase Response (rad)')

    >> xlabel('hat(\omega)')

    n x n n0 =

    bn01=

    H ej e j

    n0 1 n0= =

    0 0.5 1 1.5 2 2.5 30

    0.5

    1

    Magnitude

    Response

    0 0.5 1 1.5 2 2.5 3

    2

    0

    2

    PhaseResponse(rad)

    hat()

    n0 4=

    4

    Constant magnitude (gain) response

    Linear Phase

    MATLABwraps thephase mod2

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    20/32

    Graphical Representation of the Frequency Response

    ECE 2610 Signals and Systems 620

    Example: First-Difference System

    The frequency response is

    >> w = -pi:pi/100:pi;

    >> H = freqz([1 -1],1,w); %use a custom w axis

    >> subplot(211)

    >> plot(w,abs(H))

    >> axis([-pi pi 0 2]); grid; ylabel('Magniude Response')

    >> subplot(212)

    >> plot(w,angle(H))>> axis([-pi pi -2 2]); grid;

    >> ylabel('Phase Response (rad)')

    >> xlabel('hat(\omega)')

    y n x n x n 1 =

    H ej 1 e j 1 cos j sin+= =

    3 2 1 0 1 2 30

    0.5

    1

    1.5

    2

    MagnitudeResponse

    3 2 1 0 1 2 32

    1

    0

    1

    2

    PhaseRe

    sponse(rad)

    hat()

    2 2 sin

    sin1 cos----------------------

    atan

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    21/32

    Graphical Representation of the Frequency Response

    ECE 2610 Signals and Systems 621

    Example: A Simple Lowpass Filter

    The frequency response is

    >> w = -pi:pi/100:pi;

    >> H = freqz([1 2 1],1,w);

    >> subplot(211)

    >> plot(w,abs(H))

    >> axis([-pi pi 0 4]); grid;

    >> ylabel('Magnitude Response')>> subplot(212)

    >> plot(w,angle(H))

    >> axis([-pi pi -pi pi]); grid;

    >> ylabel('Phase Response (rad)')

    >> xlabel('hat(\omega)')

    n x n 2x n 1 x n 2 + +=

    H ej

    1 2ej

    ej2

    + + ej

    2 2 cos+ = =

    3 2 1 0 1 2 30

    1

    2

    3

    4

    MagnitudeRes

    ponse

    3 2 1 0 1 2 3

    2

    0

    2

    PhaseResponse(rad)

    hat()

    2 2 cos+

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    22/32

    Cascaded LTI Systems

    ECE 2610 Signals and Systems 622

    Cascaded LTI Systems

    Cascaded LTI system were discussed in Chapter 5 from the

    time-domain standpoint

    In the frequency-domain there is an alternative view of the

    input/output relationships

    To begin with consider again

    (6.25)

    With LTI #1 followed by LTI #2, the output at frequency is

    (6.26)

    x n ejn n =

    y1 n H2 ej H1 e

    j ejn =

    H2 ej

    H1 ej

    ejn

    =

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    23/32

    Cascaded LTI Systems

    ECE 2610 Signals and Systems 623

    With LTI #2 followed by LTI #1, the output at frequency is

    (6.27)

    Since , it follows that

    , and we have established that the frequency

    response for a cascaded system is simply the product of the

    frequency responses

    (6.28)

    We have also shown that a convolution in the time-domain is

    equivalent to a multiplication in the frequency-domain

    (6.29)

    Example: Two System Cascade

    Consider

    The cascade frequency response is

    2 n H1 ej H2 e

    j ejn =

    H1 ej H2 ej ejn=

    H1 ej H2 e

    j H2 ej H1 e

    j =y1 n y2 n =

    Hcascade ej H ej H1 ej H2 ej = =

    Time Domain Frequency Domain

    h n h1 n *h2 n = H1 ej

    H2 ej

    H ej

    =

    H1 ej 1 e j +=

    H2 ej

    1 2ej

    ej2

    + +=

    H ej 1 e j

    + 1 2e

    je

    j2+ + =

    1 3ej

    3ej2

    ej3

    + + +=

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    24/32

    Moving Average Filtering

    ECE 2610 Signals and Systems 624

    Given the cascade frequency response we can easily convert

    back to the impulse response of the cascade difference equa-

    tion

    and

    Check

    Moving Average Filtering

    The moving average filter occurs frequency enough that we

    should consider finding a general expression for the fre-quency response

    The difference equation for anL-point averager is

    (6.30)

    The frequency response is

    (6.31)

    h n n 3 n 1 3 n 2 n 3 + + +=

    n x n 3x n 1 3x n 2 x n 3 + + +=

    h1 n *h2 n

    n 1

    L--- x n k

    k 0=

    L 1

    =

    H ej

    1

    L--- e

    jk

    k 0=

    L 1

    =

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    25/32

    Moving Average Filtering

    ECE 2610 Signals and Systems 625

    This sum is known as afinite geometric series

    It can be shown (discussed in class) that

    (6.32)

    Apply (6.32) to (6.31) by setting

    (6.33)

    Notice that the phase response is composed of a linear term

    and due to the sign changes of /

    In MATLAB

    can be used for analyzing moving average filters

    k

    k 0=

    L 1

    1 L1 ---------------, 1

    L, 1 (why?)=

    =

    ej

    =

    H e

    j

    1

    L---

    1 ejL

    1 ej

    ----------------------

    =

    1

    L---

    ejL 2

    ejL 2

    ej L 2

    ej 2

    ej 2

    ej 2

    ----------------------------------------------------------------

    =

    L 2 sin

    L

    2 sin

    --------------------------- e j L 1

    2=

    ej L 1 2 L 2 sin

    L 2 sin

    DL ej

    diric L L 2 sin

    L 2 sin---------------------------= =

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    26/32

    Moving Average Filtering

    ECE 2610 Signals and Systems 626

    Plotting the Frequency Response

    The frequency response can be plotted most easily using

    MATLABs freqz() function

    Consider a 10-point moving average

    >> w = -pi:pi/500:pi;

    >> H = freqz(ones(1,10)/10,1,w);

    >> subplot(211)

    >> plot(w,abs(H))

    >> grid; axis([-pi pi 0 1])

    >> ylabel('Magnitude Response')

    >> subplot(212)

    >> plot(w,angle(H))

    >> grid; axis([-pi pi -pi pi])

    >> ylabel('Phase Response (rad)')

    >> xlabel('hat(\omega)')

    3 2 1 0 1 2 30

    0.5

    1

    Magnitude

    Response

    3 2 1 0 1 2 3

    2

    0

    2

    PhaseRes

    ponse(rad)

    hat()

    L = 10

    ej4.5

    on this segment

    2L------=

    5--- 2

    5------

    35

    ------45

    ------

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    27/32

    Filtering Sampled Continuous-Time Signals

    ECE 2610 Signals and Systems 627

    Filtering Sampled Continuous-Time Signals

    Consider the system model as shown below

    Suppose that

    (6.34)

    We know that after sampling we have

    (6.35)

    The key relationship to connect the continuous-time and the

    discrete-time quantities is

    (6.36)

    As long as the input analog frequency satisfies the sampling

    theorem, i.e., or , the output of the dis-

    crete-time system will be

    x t Xejt

    = t

    x n x nTs XejnTs

    Xejn

    = = =

    Ts 2f

    fs---= =

    Ts----- fs= =

    f

    2Ts------------

    2------

    fs= =

    Ts f fs 2

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    28/32

    Filtering Sampled Continuous-Time Signals

    ECE 2610 Signals and Systems 628

    (6.37)

    We can write in terms of the analog frequency variable

    via

    (6.38)

    At the output of the D-to-C converter we have the recon-

    structed output

    (6.39)

    wherefis the input analog sinusoid frequency (perhaps a bet-

    ter notation would be )

    Example: Lowpass Averager

    Consider a 5-point moving average filter wrapped up

    between a C-to-D and D-to-C system

    We assume a sampling rate of 1000 Hz and an input com-

    posed of two sinusoids

    Find the system frequency response in terms of the analog

    frequency variablef, and find the steady-state output

    We will use freqz() to obtain the frequency response>> w = -pi:pi/100:pi;

    >> H = freqz(ones(1,5)/5,1,w);

    >> subplot(211)

    y n H ej Xejn=

    y n

    Ts=

    y n H ejTs Xe

    jTsn=

    t H ejTs Xe

    jt=

    H ej2f fs Xe

    j 2f fs t=

    0 0 0

    x t 2 100 t cos 3 2 300 t cos+=

    t

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    29/32

    Filtering Sampled Continuous-Time Signals

    ECE 2610 Signals and Systems 629

    >> plot(w,abs(H))

    >> axis([-pi pi 0 1]); grid

    >> ylabel('Magnitude Response')

    >> subplot(212)

    >> plot(w,angle(H))>> axis([-pi pi -pi pi]); grid

    >> ylabel('Phase Response (rad)')

    >> xlabel('hat(\omega)')

    >> subplot(211)

    >> plot(w*1000/(2*pi),abs(H))

    >> grid

    >> ylabel('Magnitude Response')>> subplot(212)

    >> plot(w*1000/(2*pi),angle(H))

    >> grid

    >> ylabel('Phase Response (rad)')

    >> xlabel('f (Hz)')

    3 2 1 0 1 2 30

    0.5

    1

    Magnitude

    Response

    3 2 1 0 1 2 3

    2

    0

    2

    PhaseRes

    ponse(rad)

    hat()

    Magnitude and Phase Plots ofH ej

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    30/32

    Filtering Sampled Continuous-Time Signals

    ECE 2610 Signals and Systems 630

    The output will be of the same form as the input ,

    except the sinusoids at 100 and 300 Hz need to have the filterfrequency response applied

    Note 100 Hz and 300 Hz < 1000/2 = 500 Hz (no aliasing)

    To properly apply the filter frequency response we need to

    convert the analog frequencies to the corresponding discrete-

    time frequencies

    (6.40)

    500 400 300 200 100 0 100 200 300 400 5000

    0.5

    1

    MagnitudeR

    esponse

    500 400 300 200 100 0 100 200 300 400 5004

    2

    0

    2

    4

    PhaseResponse(rad)

    f (Hz)

    Magnitude and Phase Plots ofH ej2f fs

    t x t

    100Hz 2100

    1000------------ 2 0.1 0.2= =

    300Hz 2300

    1000------------ 2 0.3 0.6= =

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    31/32

    Filtering Sampled Continuous-Time Signals

    ECE 2610 Signals and Systems 631

    The frequency response for in the general moving

    average filter is

    (6.41)

    The frequency response at these two frequencies is

    (6.42)

    >> diric(0.2*pi,5)

    ans = 0.6472

    >> diric(0.6*pi,5)

    ans = -0.2472 % also = 0.2472 at angle +/- pi

    The filter output is

    (6.43)

    and the D-to-C output is

    (6.44)

    L 5=

    H e

    j

    2.5 sin5 2 sin--------------------------- e

    j2

    =

    H ej0.2

    2.5 0.2 sin5 0.2 2 sin---------------------------------------e

    j2 0.2 0.6472e

    j0.4= =

    H ej0.6

    2.5 0.6 sin

    5 0.6 2 sin---------------------------------------e

    j2 0.6 0.2472e

    j1.2= =

    0.2472e j0.2

    y n

    n 0.6472 0.2n 0.4 cos=

    0.7416+ 0.2n 1.2 + cos

    y t 0.6472 2 100 t 0.4 cos=

    0.7416+ 2 300 t 0.2 cos

  • 8/2/2019 Chap6_Frequency Response of FIR Filters

    32/32

    Filtering Sampled Continuous-Time Signals

    Interpretation of Delay

    In the study of the moving average filter, it was noted that

    where is a purely real function

    The pure delay system

    has impulse response

    and has frequency response

    We also know that the impulse response of two systems in

    cascade is

    The L-point moving average filter thus incorporates a delay

    of samples

    Viewed as a cascade of subsystems

    (6.45)

    IfL is odd then the delay is an integer

    IfL is even then the delay is an odd half integer

    H e

    j

    DL ej

    ej L 1 2

    =

    DL ej

    n x n n0 =

    h n n n0 =

    H ej e

    jn0=

    h n h1 n *h2 n =

    H ej H1 e

    j H2 ej =

    L 1 2

    H ej DL e

    j e j L 1 2=