Filter Analysis and Design

Analysis of an Analog Filter

The Signals and Systems package is fully integrated with Mathematica. You can solve problems using the Mathematica techniques you already know.

We begin by defining an analog pole­zero filter.

anfilt = AnalogFilter[{-1, -2, 3}, {-3, -4}, t];

The filter is defined by its poles, zeros, and variable. Because the package is oriented towards symbolic manipulation, it is usually necessary to specify a variable name with signal processing expressions.
This filter is known to be unstable because one of its poles is positive. We can get a bit of information about it by using some of the analysis functions of the package.

ltrans = LaplaceTransform[anfilt, t, s]
[Graphics:fad_gr_1.gif]
PoleZeroPlot[ltrans]

[Graphics:fad_gr_2.gif]

SignalPlot[
    EvaluateOperators[anfilt[DiracDelta[t]]],
    {t, 0, 8}]
Signals and Systems is oriented around manipulating signals, which are described in simple terms as varying quantities, and systems, which transform or operate on those quantities. In the package, a filter is treated as a particular kind of system. To allow various forms of symbolic manipulation of cascaded systems, a system applied to a signal does not immediately evaluate. The EvaluateOperators function forces evaluation and generates the signal that results from passing the input through the system. In the case of an impulse function transformed by a filter, we find the impulse response. (For more information on the representation of signals and systems, see Chapter 2 of Signals and Systems.)
A variety of tools for filter design (among other things) can be found in the package. One routine commonly used for converting analog filters to digital filters is the bilinear transform. (For details on the bilinear transformation and other filter design tools, see Chapter 4 Signals and Systems.)

Analysis of a Digital Filter

Here is the digital filter that results from applying the bilinear transform with a design constant of 3 to the analog filter

digfilt = BilinearTransformation[ anfilt, 3, t, n ]
[Graphics:fad_gr_6.gif]

The Signals and Systems package does not require you to apply each analysis function separately; for common signal analysis procedures, the omnibus functions ASPAnalyze and DSPAnalyzeare available to simplify the proceedings in the continuous­time and discrete­time domains, respectively.

This creates a general report about the input, which in this case is the designed digital function. The iterator specifies a range for the time­domain analysis.

DSPAnalyze[digfilt, {n, 0, 10}]

[Graphics:fad_gr_7.gif]

Result of Digital Filter
Given the input function:
                  1  1         1
-7 DigitalFilter[{-, -}, {0, -(-), -1}, n]
                  2  5         7
------------------------------------------
                    20
The z-transform is:
  z (1 + z) (1 + 7 z)
-(-------------------)
                  2
   2 - 14 z + 20 z
The region of convergence is:
1
- < |z| < Infinity
2

    The system is stable

The zeroes are:  {-1., -0.142857, 0}
The poles are:   {0.2, 0.5}

[Graphics:fad_gr_8.gif]

Since the sequence is stable with the default values assumed for any of the parameters, the frequency response can be computed directly from the z-transform.
The frequency response is:
 I w      2 I w      3 I w
E    + 8 E      + 7 E
--------------------------
          I w       2 I w
-2 + 14 E    - 20 E
Magnitude and Phase Response of Filter

[Graphics:fad_gr_9.gif]

[Graphics:fad_gr_10.gif]

[Graphics:fad_gr_11.gif]

We see the (possibly surprising) result that the bilinear transformation can create a stable digital filter from an unstable analog filter! The analysis shows that the digital filter behaves much like a notch filter (although the falloff may be too rapid for many practical applications). The stable design is achieved by setting the design parameter of the bilinear transformation equal to one of the poles. This effectively removes the pole from the corresponding digital design, possibly stabilizing the filter.
Classical analog filter design techniques are also available. For instance, in this example we design a bandstop filter.

Design of an Analog Bandstop Filter

Here is an analog bandstop filter specification. First, the filter's magnitude response characteristics must be described.  N is being applied by the postfix notation to the filter specification.

bsfiltspec = FilterSpecification[
    Passband[0.1, {0, 0.2 Pi}],
    Stopband[0.01, {0.3 Pi, 0.4 Pi}],
    Passband[0.1, { 0.5 Pi, Infinity}]
]//N;

Here we find an elliptic filter that meets or exceeds the given specification.

anfilt =
  DesignAnalogFilter[Elliptic, t, bsfiltspec]//Chop
DesignAnalogFilter::narrower: One of the transition bandwidths will be narrower than specified.
[Graphics:fad_gr_12.gif]

The function Chop may be used to remove small complex values that result from rounding error. Be careful with its use; employ only  it where the small values are insignificant.

We can easily examine the frequency response of the filter.

MagnitudePhasePlot[
FourierTransform[anfilt, t, w],
    {w, 0, Pi}
];

[Graphics:fad_gr_13.gif]

[Graphics:fad_gr_14.gif]

This is just a sampling of filter design techniques and a few of the analysis functions available to you in the Signals and Systems package. These examples will help familiarize you with the appearance and syntax of functions in the package.