InterludeA Quick Start
This section presents a short and interesting example for the impatient reader. It demonstrates some of the key features of Signals and Systems used to analyze and design filters. Of course, a host of other features are provided, and are documented in the following chapters.
To access the functionality, it is first necessary to load the initialization package.
This loads Signals and Systems.
In[1]:=Needs["SignalProcessing`"]
An initialization package doesn't actually load the routines; instead, it sets up code enabling the functions to be loaded only when you use them. This can conserve system resources while using these routines.
Signals and Systems is fully integrated with Mathematica. You can use all the ways of working with Mathematica you are already familiar with to solve your problems.
We begin by defining an analog polezero filter.
In[2]:=anfilt = AnalogFilter[{1, 2, 3}, {3, 4}, t];
The filter is defined by its poles, zeros, and variable. Because the provided routines are 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 provided.
Here is the Laplace transform of the analog filter.
In[3]:=ltrans = LaplaceTransform[anfilt, t, s]
Out[3]=
We can generate a polezero plot from the transfer function.
In[4]:=PoleZeroPlot[ltrans]
Out[4]=
We can also generate a plot of the impulse response. Note that this analog filter is unstable.
In[5]:=SignalPlot[ EvaluateOperators[anfilt[DiracDelta[t]]], {t, 0, 8} ]
Out[5]=
Signals and Systems is oriented around manipulating signals, which are described in simple terms as varying quantities, and systems, which transform those quantities, or operate on them. In these routines, 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.)
A variety of tools for filter design (among other things) can be found in Signals and Systems. 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.)
Here is the digital filter that results by applying the bilinear transform with a design constant of to the analog filter.
In[6]:=digfilt = BilinearTransformation[ anfilt, 3, t, n ]
Out[6]=
Signals and Systems does not require you to apply each analysis function separately; for common signal analysis procedures, the omnibus functions ASPAnalyze and DSPAnalyze are available to simplify the proceedings in the continuous and discretetime 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 timedomain analysis.
In[7]:=DSPAnalyze[digfilt, {n, 0, 10}]
Out[7]=
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 acheived 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 the following example we design a bandstop filter. First, the filter's magnitude response characteristics must be described.
Here is an analog bandstop filter specification. N is being applied by the postfix notation to the filter specification.
In[8]:=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.
In[9]:=anfilt = DesignAnalogFilter[Elliptic, t, bsfiltspec]//Chop
Out[9]=
The function Chop may be used to remove small complex values that result from rounding error. Be careful with its use; only employ it where the small values are insignificant.
We can easily examine the frequency response of the filter.
In[10]:=MagnitudePhasePlot[ FourierTransform[anfilt, t, w], {w, 0, Pi} ];
This is just a sampling of filter design techniques and a few of the analysis functions available to you in Signals and Systems. These examples will help familiarize you with the appearance and syntax of functions now available to you. Full details of the use of these functions can be found in the following chapters.
