3.4 Introduction to Analog and Digital Filters
This section presents some basic concepts of analog and digital filters.
3.4.1 Frequency response: Fourier transform of the impulse response
As indicated in Table 3.1, the frequency response of an LTI system is the Fourier transform of its impulse response. In continuous-time it will be denoted by ( in Hz) or ( in rad/s), while in discrete-time the notation is ( in rad). The frequency response is particularly useful because complex exponentials are eigenfunctions of LTI systems as explained in the sequel.
Eigenfunctions
Eigenfunctions are closely related to eigenvectors. if is a matrix (a linear transformation), a non-null vector is an eigenvector of if there is a scalar such that
The scalar is an eigenvalue of corresponding to the eigenvector . In general, the matrix generates a completely new vector , i. e., and have different directions and magnitudes. However, if is an eigenvector of , then , which means that the operation changed only the magnitude of , leaving its direction unchanged (or possibly reversing it in case ).
Similarly, for any LTI system (continuous-time is assumed here), a complex exponential is an eigenfunction because the output is when the input is . The frequency response is useful because the eigenvalue is the value of the frequency response at the specific frequency .
It is then possible to analyze an LTI in the frequency domain by following the next steps:
- f 1.
- Using the Fourier transform to decompose a non-periodic input as an integral of complex exponentials.
- f 2.
- Obtain the frequency response of the system with impulse response . The frequency response provides the eigenvalue for any input of frequency .
- f 3.
- Conceptually, multiply each complex exponential at the system input by its eigenvalue and add the partial results to obtain the system output . In practice, this step is performed by and then using the inverse transform to obtain .
The previous steps are slightly different in case the input signal is periodic. In this case, the Fourier series is used to represent the input signal as a summation (instead of an integral) of complex exponentials.
Example 3.7. LTI filtering of continuous-time complex exponential. For example, consider that is the input of an LTI with . The eigenvalues corresponding to each the complex exponential eigenfunctions with frequencies rad/s can be obtained from the frequency response . The Matlab/Octave commands Omega=4; H=1/(j*Omega+2) calculate for the positive frequency. Because is real-valued, the frequency response presents Hermitian symmetry and , i. e., . The commands abs(H), angle(H) can be used to convert the complex numbers from the Cartesian to the polar representation: and . Therefore, the output is .
The effect of the LTI system was to impose to the input a gain of and a phase of rad that shows up at the output . Figure 3.5 depicts the frequency response for a range rad/s. Because of the Hermitian symmetry (when is real), it is common to plot only the positive frequencies. For example, investigate the command freqs(1,[1 2]), which shows the frequency response of in a different format.
Result 3.1. LTI systems cannot create new frequencies. The previous discussion implies that an LTI never creates new frequencies, because it can simply change the magnitude and phase of frequencies that were presented at its input. This fact can be represented as
Note that a linear time-varying (LTV) system can generate new frequency components, just as a nonlinear time-invariant (NLTI) system can. Only when a system is both linear and time-invariant (LTI) does the restriction apply that no new frequencies can be created.
The previous discussion was restricted to exponentials of the form , but a general complex exponential (with ) is also an eigenfunction of any LTI and the eigenvalue is given by the Laplace transform , as represented by
The frequency response of discrete-time LTI systems is also very useful. When the time axis is discretized by sampling, i. e., , the complex exponential becomes , which is more conveniently represented by , where
with .
The discrete-time complex exponential is an eigenfunction of discrete-time LTI systems. To prove that, consider , then
The eigenvalue can be obtained from the transfer function
which is the Z-transform of the system’s impulse response. As a special case, when , the eigenfunction has its amplitude and phase eventually modified by a LTI as depicted by:
Example 3.8. LTI filtering of discrete-time complex exponentials. This example describes how an LTI system filters a complex exponential. Consider that is the input of an LTI with . The eigenvalues can be obtained from when rad. The Matlab/Octave commands omega=pi/2; H=1/(1-0.7*exp(-j*omega)) calculate . Because is real-valued, the frequency response presents Hermitian symmetry. The commands abs(H), angle(H) can transform from Cartesian to polar: . Therefore, the output is . The effect of the LTI system was to impose a gain of and a phase of rad.
Figure 3.6 depicts the frequency response for a range rad. As expected, is periodic because . Given this periodicity and the Hermitian symmetry (when is real), it is common to plot only the positive frequencies in the range . For example, Figure 3.7 shows the plots obtained with the command freqz(1,[1 -0.7]), which shows the frequency response of with the magnitude in dB, the phase in degrees (instead of rad) and the abscissa in a “normalized frequency” that maps into .
3.4.2 A quick discussion about analog filters
This section presents a brief introduction to a special class of systems called LTI filters, which typically have the characteristic of being frequency-selective. LTI systems will be further discussed in Section 3.3 but the goal here is to provide concrete examples on frequency-selective filters, due to their importance in DSP. Other filters will be discussed, but this section starts with the two most common filters: lowpass and highpass.
The lowpass filter is characterized by attenuating (or rejecting) the frequency components that are above a given frequency called bandpass frequency , while providing a gain to the frequency components from 0 to . The name lowpass is used because the filter allows the low-frequency components of to “pass” and compose the output. Similarly, the highpass tries to reject the components of that are located from 0 to its in the frequency spectrum, while keeping those higher than .
Figure 3.7a and Figure 3.7b depict the ideal specification of low and highpass filters, respectively. These figures only illustrate the magnitude (gain ) and, at this moment, the phase is assumed to be zero.
Example 3.9. Lowpass and highpass filtering examples. For example, assume a signal ( in seconds) is the input to the lowpass filter of Figure 3.7a with , and Hz. The output would be because the component of frequency 200 Hz would be filtered out. If the same is the input to the highpass filter of Figure 3.7b with , and Hz, the output would be . In this case, besides eliminating the lowpass component, the filter imposed a gain of 4 to the amplitude of the 200 Hz component.
Figure 3.9 shows the magnitude of the frequency response of a (second order analog) filter. This figure should be contrasted to the ideal case of Figure 3.8. In practice the filter gain cannot instantaneously change from 1 to 0 as idealized in Figure 3.8. Instead, this variation (the attenuation rolloff) depends on the filter order and creates a transition region that is defined as the range of frequencies between and the stopband frequency .
3.4.3 Cutoff and natural frequencies
Besides and , another frequency of interest is the so-called cutoff frequency . Assuming the filter gain at the passband is , the cutoff is the frequency for which the linear gain is . The cutoff indicates the frequency in which the filter attenuates a signal component to half of its power at the passband center. For example, assume an input signal has a component with power , which is passed through a highpass filter with unitary gain at passband and cutoff frequency . This component will show up at the filter output as , which has power , corresponding to half of the original power. In dB scale, the cutoff frequency corresponds to a gain of dB, as illustrated in Figure 3.9 for a lowpass filter with gain at DC.
The cutoff frequency should not be confused with the natural frequency, which is detailed in Figure 3.10. Table 3.2 is a useful reference for the special frequencies used in signal processing.
| Symbol | Description | Reference |
| or | Cutoff frequency: where gain falls by ( dB) | Figure 3.9 |
| Natural frequency, for example, of a resonator | Figure 3.10 | |
| Center frequency of a pole | Figure 3.10 | |
| Passband frequency | Figure 3.9 | |
| Stopband (or rejection) frequency | Figure 3.9 | |
| Sampling frequency (typically in Hz or samples per sec.) | Eq. (1.26) | |
| Nyquist (or folding) frequency | Eq. (2.36) | |
3.4.4 First and second-order analog systems
Because they are basic building blocks for higher-order systems, first and second-order continuous-time (also called analog) systems are discussed in this section.
First-order systems
If the coefficients are real, a first-order system , (as the one whose frequency response is depicted in Figure 3.5) is restricted to have a lowpass frequency response. This has a pole at and a zero at . Using leads to a unitary gain at DC. Placing a zero at leads to , which has a highpass response.
A system with ROC given by has an inverse Laplace transform , which can be written as where is the well-known time constant [ url3mit] of the system’s impulse response. After an interval of one time constant, the impulse response has decayed to 36.8% of its initial value.
If the ROC of includes , the frequency response in this case is . As illustrated by Eq. (3.24), the magnitude at is then , which is the cutoff frequency because it corresponds to a decrease of 3 dB in power.
Second-order systems
The system function of a second-order system (SOS), also called a two-pole resonator, has a denominator that can be written as . When there are two zeros at and the gain at DC is unitary (), the SOS is:
|
| (3.17) |
where is the natural frequency and the decay rate parameter, which is useful for defining the damping ratio . Hence, Eq. (3.17) can be rewritten as:
|
| (3.18) |
Example 3.10. Second-order Butterworth filter. For a generic second-order system, the natural frequency , the pole frequency , and the cutoff frequency are generally different. However, for a Butterworth lowpass filter, the damping ratio is , and the transfer function can be written as
In this special case, the magnitude response satisfies , corresponding to a dB attenuation relative to the passband gain. Therefore, the cutoff frequency coincides with the pole frequency: .
For example, a second-order Butterworth filter with rad/s has a cutoff frequency Hz.
The values of , and can be related to several characteristics of a SOS. For example, represents the rate of exponential decay of oscillations when the system input is a unit step . And depending on , three categories of second-order systems are defined:
- : critically damped SOS, with a double real pole at ;
- : overdamped SOS, with real poles at ;
- : underdamped SOS, with complex conjugate poles.
Note that these three categories depend only on the denominator of .
The numerator of represents another degree of freedom. Changing this numerator, leads to distinct SOS. An alternative to Eq. (3.17) (or, equivalently, Eq. (3.18)) is
|
| (3.19) |
which has a zero at the origin (). Yet, other two options of SOS can be defined as
|
| (3.20) |
and
|
| (3.21) |
Table 3.3 summarizes these options for the numerator of a SOS.
Using the quadratic formula to find the roots of a SOS, the poles are , which can be rewritten as . Figure 3.10 summarizes these relations. Note that and, unless (poles on the axis), the natural frequency is different from the center frequency of the pole .
Note that for a first-order system with real-valued coefficient , the pole is real, its center frequency is , and the natural and cutoff frequencies coincide. For a second-order system, the expression for the cutoff frequency is more elaborated. Considering Eq. (3.17), the cutoff is
|
| (3.22) |
which can be found by using . In this case, when .
Example 3.11. On the damping ratio of a SOS. Figure 3.11 illustrates the influence of the damping ratio using the values and 2.
Figure 3.11 also compares Eq. (3.18) and Eq. (3.21), which are two of the options contrasted in Table 3.3.
Figure 3.12 illustrates some key time-domain performance parameters for an underdamped system obtained when the input is a step function. The rise time is the interval for the step response to rise from 10 to 90% of its final value. The settling time is the interval to have the output within a given range, which is 5% in Figure 3.12. The overshoot is the peak amplitude and occurs at the peak time .
Table 3.4 summarizes some parameters for the system described by Eq. (3.18), which can be found3 from the inverse Laplace transform of given that is the transform of . The tolerance is used to obtain and a typical value is .
| Performance parameter | Expression | For |
| Peak time | ||
| Rise time | ||
| Settling time | ||
| Overshoot | ov=4.32% | |
| 3-dB bandwidth (rad/s) | ||
Table 3.4 indicates that, for an underdamped system, the rise time when is . As expected, all three time parameters are inversely proportional to the natural frequency .
Listing 3.8 indicates the commands to calculate the parameters, emphasizing the factors that depend on (zeta) only.
1zeta=0.5 %damping ratio, e.g. sqrt(2)/2 = 0.707; 2wn=2 %natural frequency in rad/s 3epsilon=0.05 %tolerance for the settling time (5% in this case) 4tp_factor=pi/sqrt(1-zeta^2) %depends on zeta only 5tp=tp_factor/wn %peak time 6tr_factor=(2.23*zeta^2 - 0.078*zeta + 1.12)/sqrt(1-zeta^2) %zeta only 7tr=tr_factor/wn %rise time 8ts_factor= -log(epsilon * sqrt(1-zeta^2))/(zeta) %zeta only 9ts=ts_factor/wn %settling time 10ov=exp(-(zeta*pi)/sqrt(1-zeta^2)) %overshoot (depends on zeta only) 11bw_factor=sqrt(1-2*zeta^2 + sqrt(2 - 4*zeta^2 + 4*zeta^4)) %zeta only 12wc=wn*bw_factor %cutoff frequency=3-dB bandwidth (in radians/second) 13%% Check whether the cuttoff frequency wc corresponds to a -3 dB gain 14s = 1j*wc %define s = j wc 15Hs = (wn^2) / (s^2 + 2*zeta*wn*s + (wn^2)) % system function 16gain_at_wc = 20*log10(abs(Hs)) %answer is -3.0103 dB
Matlab has the stepinfo function, which can be used to obtain most of the parameters in Table 3.4 as follows:
1zeta=0.5 %damping ratio, e.g. sqrt(2)/2 = 0.707; 2wn=2 %natural frequency in rad/s 3sys = tf([wn^2],[1 2*zeta*wn wn^2]); %define the transfer function 4S=stepinfo(sys,'RiseTimeLimits',[0.1,0.9], ... 5 'SettlingTimeThreshold',0.05) %get parameters with stepinfo 6step(sys) %plot step response to check results if want
The system bandwidth will be discussed in the next section. Table 3.4 informs that, when , the 3-dB bandwidth in radians per second of the SOS given by Eq. (3.18) is simply its natural frequency . In fact, as varies from 0.5 to 0.8, which are the values typically used, its varies from to . This justifies using as a rough approximation of bandwidth for Eq. (3.18).
Example 3.12. Basic filtering using an electronic circuit simulator. The Falstad’s circuit simulator [ url3fac] can help learning analog filters. In the menu bar, choose Circuits and look for the options in Passive Filters and Active Filters. For instance, Figure 3.12a illustrates a simple low-pass filter with cutoff frequency Hz. The signal source (at the left) is a sine sweep that generates4 sinudoids from 20 Hz to 1kHz during a sweep time of 100 ms. In the figure, the current input signal corresponds to a sinusoid with frequency of 885.1 Hz. As shown by the two scopes in the bottom of Figure 3.12a, this sinusoid at 885.1 Hz is clearly attenuated by this filter given that the amplitude of the output signal is significantly smaller than the input signal amplitude.
Figure 3.12b shows an example of an active low-pass filter with order equals to six.5 The input source generates noise and the scope at the bottom shows the time-domain signal output (in green) and its spectrum (in red). The reader is invited to browse this site and learn with the simulator.
3.4.5 Bandwidth and quality factor
Bandwidth and quality factor of poles
The overall behavior of a filter is dictated by the combined effect of its poles and zeros. The position of a pole in the or plane determines how it influences the overall system function ( or , respectively).
It can be shown that asymptotically each pole contributes with a roll-off of 20 dB per decade (equivalent to 6 dB per octave) and a zero with an increase of 20 dB per decade. This asymptotic behavior is used to obtain graphs known as Bode diagrams. This clearly indicates that the sharpness of a frequency response (shorter transition regions) can be improved by increasing the order of the corresponding system function (or ), i. e., adding poles and/or zeros. However, increasing the order of an analog filter requires more components (capacitors, opamps, etc.) and for a digital filter it requires more multiplications and additions. Hence, it is important to make the best use of poles (and zeros) and, motivated by that, to have figures of merit for them.
Besides its frequency, the bandwidth and quality factor of a single pole or zero are important to assess its influence. Poles will be emphasized in this section, but similar definitions are applied to zeros. This section discusses characteristics of a single pole while Section 3.4.6 extends the definitions to filters.
Bandwidth of a pole
The bandwidth of a pole is illustrated in Figure 3.14 and defined here as , where the cutoff frequencies and are those in which the gain at the center frequency (that may be different than the natural frequency ) has decreased to . The factor corresponds to dB, or approximately dB. Therefore, this definition is called the 3-dB bandwidth or half-power BW.
Pole bandwidth in continuous-time
Assuming a first-order system , where is the pole, the bandwidth of in Hz is given by
|
| (3.23) |
This result can be obtained by noting that for any frequency
Hence, the squared gain at the specific pole frequency is
and the squared gains at cutoff frequencies fall to as required by the definition of cutoff frequency:
|
| (3.24) |
Hence, a range from to is determined by the two cutoff frequencies of a pole at such that its bandwidth is rad/s. Dividing by leads to in Hz, as indicated in Eq. (3.23). A similar relation holds in discrete-time, as follows.
Pole bandwidth in discrete-time
Using the previous results and assuming the transformation of Eq. (2.66), the pole in the plane is mapped into the pole in the plane via
Hence, and . Assuming for a causal and stable , Eq. (3.23) indicates that , such that and
|
| (3.25) |
in Hz for a pole in the plane with .
One can rewrite Eq. (3.25) as and use the Taylor series expansion of around a value
with , to keep only the first two terms and achieve
Hence, the approximation allows to write
|
| (3.26) |
which can be used when is close to 1.
Quality factor of poles
Besides the number of poles and zeros, another factor that influences the sharpness of a frequency response is the quality factor (or -factor) of each pole, which is defined as
|
| (3.27) |
where is the natural frequency in Hz and is the 3-dB bandwidth (also in Hz), as indicated in Figure 3.14.
For a second-order resonator, such as Eq. (3.17), the quality factor can be shown [ url3dsp] to be
|
| (3.28) |
Appplication 3.1 presents a discussion on the influence of the Q-factor in frequency responses.
3.4.6 Bandwidth and quality factor of filters
The previous definitions of bandwidth and Q-factor of poles can be extended to systems, especially frequency-selective filters such as bandpass and lowpass.
Bandwidth definitions for signals and systems
For a generic system there are definitions for the bandwidth () other than the 3-dB bandwidth of Figure 3.14. In all cases, if the frequency response has Hermitian symmetry, only the positive frequencies are taken in account.
A generalization of BW is to adopt the -dB bandwidth where is the attenuation of interest, such as 1 dB.
Alternatively, the absolute bandwidth can be applied when the signal is bandlimited. It is simply defined as the frequency range in which the spectrum is non-zero. For example, has . Note that in this case the 3-dB BW definition would not be appropriate.
Another alternative definition of is the so-called null-to-null or zero-crossing BW. In the case of a lowpass spectrum, the BW is determined by the first null of (or in discrete-time). For example, a frequency response given by the of Eq. (B.14) has according to this definition. For a passband spectrum, the two neighbor nulls of the center frequency determine BW. For example, the BW of is .
When a signal is complex-valued, its spectrum does not have to exhibit Hermitian symmetry. In this case, the sampling theorem and other results depend on the double-sided or bilateral bandwidth, which takes in account the support of from negative to positive frequencies.
For example, first consider the “conventional” case of corresponding to a real-valued ideal lowpass filter with unitary gain from to 200 Hz: its BW is 200 Hz, and its double-sided bandwidth is 400 Hz. Contrast now with a complex-valued signal with being a square pulse from to 100 Hz as depicted in Figure 3.34. In the latter case, the double-sided bandwidth continues to be 400 Hz but the conventional BW fails to indicate, for example, the minimum according to the sampling theorem. In this case, the sampling theorem could be stated with respect to the double-sided bandwidth.
Another approach when dealing with complex-valued signals is to assume that is zero for negative frequencies (such signals are called “analytic”). In this case, the bandwidth BW takes in account only positive frequencies, as usual, but it may be misleading the fact that the sampling theorem in this case of an analytic signal can be stated as
|
| (3.29) |
For example, if is non-zero from DC to 300 Hz, sampling the corresponding complex-valued (analytic) time-domain signal at Hz suffices to avoid aliasing. In this case, the first spectrum replica at positive frequencies has support from 0 to 300 Hz, the second one from 350 to 650 Hz, and so on, indicating that there is no aliasing.
A bandwidth definition very useful when dealing with filtered white noise is the equivalent noise bandwidth (ENBW). The ENBW of a filter is the bandwidth of a fictitious ideal (e. g., lowpass or bandpass) filter with rectangular spectrum that obeys
|
| (3.30) |
and has the maximum value of is equal to the maximum of . The name ENBW is because both filters lead to the same output power when the input is white noise (discussed in details later, in Section 4.7.2 ) such that the equivalent filter can substitute the original (and more complicated one) while leading, for instance, to the same SNR in a simulation or theoretical development.
An example is provided in Figure 3.15, which was obtained with Matlab’s function6 enbw as informed in Listing 3.9. In this case, the ENBW was times larger than the cutoff frequency.
1Fs = 1000; %sampling frequency in Hz 2fc = 50; %filter cutoff frequency in Hz 3[B,A]=butter(4,fc/(Fs/2)); %4-th order Butterworth filter 4N=100; %number of samples in impulse response hn 5hn = impz(B,A,100); %impulse response 6Hf = fftshift(fft(hn)); %sampled DTFT 7equivalentBW = enbw(hn,Fs); %estimate equivalent noise bandwidth 8%code to plot the figure continues from here...
Observing Figure 3.15, due to the rectangular shape of ,
Hence, using Eq. (3.30) this can be written as:
|
| (3.31) |
which for real signals simplify to
|
| (3.32) |
Quality factor for filters
The Q-factor of a pole, as defined in Eq. (3.27), can be easily adapted to a system with a frequency response that allows obtaining its 3-dB bandwidth (see Figure 3.14) such as a bandpass filter.7 In this case, the pole natural frequency in Eq. (3.27) is substituted by the filter’s center frequency such that
|
| (3.33) |
The inverse of , i. e., is called fractional bandwidth and often specified in percentage.
3.4.7 Importance of linear phase (or constant group delay)
In some applications such as analog signal transmission and audio amplification, the system should ideally have an output identical to its input . Given that obtaining is often unfeasible due to propagation delays inherent of communication channels and electronic systems, a more realistic target is to obtain , a delayed version of the input. From the time-shift Fourier property (see Appendix B.1), the delay by corresponds to a linear phase in frequency domain. Hence, having a linear phase is an important property of a system to achieve distortionless transmission, i. e., letting a signal pass without distortion.
A linear phase filter with frequency response has a phase that corresponds to a line segment in the passband (the phase behavior in the stopband is considered irrelevant). In practice, the line has a negative slope because a positive slope would correspond to a non-causal behavior (the output would be an anticipated version of the input signal). Hence, it is convenient to define the group delay as:
|
| (3.34) |
Similarly, the discrete-time version is
|
| (3.35) |
with .
Example 3.13. Impact of the system phase on the output signal. To help understanding the practical importance of a system with linear phase, it is adopted a periodic pulse with (number of non-zero samples in a period) and period (see Example 2.11). The experiment is to obtain by multiplying the DTFS of by , where . Listing 3.10 carries out the operation, including the conversion of to .
1%Specify: N-period, N1/N-duty cicle, N0-delay, k-frequency 2N=50; N1=15; N0=4; k=0:N-1; 3xn=[ones(1,N1) zeros(1,N-N1)]; %x[n] 4Xk=fft(xn)/N; %calculate the DTFS of x[n] 5phase = -2*pi/N*N0*k; %define linear phase 6Yk=Xk.*exp(j*phase); %impose the linear phase 7yn=ifft(Yk)*N; %recover signal in time domain
Figure 3.16 illustrates the result: is a perfect delayed version of . The middle plot shows the phase that was added to the original phase of . The magnitude of was left unchanged but that would not be enough to keep the shape of in case the phase was not linear with frequency.
To be contrasted with the linear phase case, Figure 3.17 provides an example where the phase is 0, 2 or rad, as depicted in the top-most plot. In order to assure that is real, the phase is an odd function to preserve the Hermitian symmetry.
Note that in the case of Figure 3.17, the pulses in are severely distorted due to the effect of a non-linear phase.
Considering continuous-time (same is valid for discrete-time), a linear phase avoids distorting an input signal because the system delays all components of by the same time interval . To obtain that, a linear phase system adds to the input signal component with frequency , a phase that is proportional to (the larger , the larger the phase added by the system). The following example concerns this aspect.
Example 3.14. A linear phase allows components with distinct frequencies to be delayed by the same angle. For example, assume components corresponding to and 400 rad/s with s. The phases are 800 and 1600 rad, respectively. On the other hand, if these two components pass a system that adds a fixed phase rad to both, the delays would be 6 and 3 s, respectively, which would potentially distort the delayed version with respect to the original signal .
For non-linear phase filters, the group delay must be interpreted as an average delay that is frequency-dependent (compare Figure 3.55 and Figure 3.56).8
Example 3.15. Gaussian filter and minimum group delay. In some applications, such as digital communications, minimizing the group delay is important to achieve low latency. In this case, the Gaussian filter is competitive because it has the minimum possible group delay. As a consequence, this filter has no overshoot to an input while minimizing the rise and fall time intervals. Its ideal and non-causal impulse response is
|
| (3.36) |
where controls the 3-dB bandwidth BW. This requires truncation in practice.
More specifically, depends on the product of BW and the symbol period as follows:
|
| (3.37) |
The frequency response of this filter is and decreases with but is not zero for finite .
3.4.8 Filter masks
The filter designer often has a specification mask that should be obeyed. The passband and other special frequencies are used to describe the mask.
Figure 3.17a and Figure 3.17b depict masks for low and highpass filters, respectively. In this case, the values Apass and Astop indicate the maximum and minimum attenuation in dB for the passband and stopband, respectively. These bands are indicated by the frequencies Fp and Fr, for pass and rejection bands.
Besides lowpass and highpass, some other popular filters are the so-called bandpass and bandstop (or band-reject) filters. Figure 3.19 shows a bandpass specification.
The goal of this section was to provide an overview of filtering. Appendix B.7 presents a brief review of the most important properties of systems and the next section discusses LTI systems.
3.4.9 Designing simple filters using specialized software
Before studying digital filters in more details, it is useful to briefly discuss analog filters because most of the times they are required in digital signal processing systems as will be discussed here.
Example of analog filter design
There are integrated circuits (IC) that implement analog filters. They can also be built using discrete components: resistors, capacitors, inductors and operational amplifiers (opamps). The design of a filter corresponds to obtaining its system function. In the case of analog filters, there are many recipes (well-established algorithms, also called approximations) to obtain a system function that obeys the specified requirements in a project. The most common approximations are the Butterworth, Chebyshev, Bessel and Cauer (or elliptic).
Having , the next step is the realization of the filter using a circuit, i. e., establishing the topology and the components of the circuit that (approximately) implement . These two steps are the subject of many textbooks on filter design. Here, the approach will be to simply provide an example using software from Texas Instruments [ url3tif] that allows to obtain the schematic and components.9
Analog filters that use only resistor, capacitors and inductors are called passive filters. An alternative to avoid using inductors10 are active filters, which are typically based on opamps. When the target is an IC, not a circuit with discrete components, inductors are avoided due to the difficulty of their integration using current microelectronics technology. When an analog filtering operation is required in an IC, an active filter is typically adopted and this is the only class of filters supported by the mentioned Texas Instruments’ software.
Example 3.16. Example of analog filter designed with Texas Instruments’ software. The following example illustrates the design of an analog filter with a desired cutoff frequency kHz, which is assumed to define the passband, such that the passband frequency is . A second-order lowpass filter with passband frequency of approximately Hz was obtained with Texas Instruments’ software and its schematic11 is shown in Figure 3.20.
The system function can be obtained by analyzing the circuit in Figure 3.20 and is given by
|
| (3.38) |
where the suffix “_S1” (meaning “stage 1”) was removed from the names of the components in Figure 3.20. For instance, in Eq. (3.38) corresponds to R2_S1 in Figure 3.20. Note the minus signal in of Eq. (3.38) because the circuit corresponds to an inverting topology.
Substituting the component values , , and into Eq. (3.38) yields
Rearranging the denominator into the standard second-order form,
which has a cutoff frequency Hz.12
The ideal system function can be obtained e. g. with Matlab/Octave via the command: [Bs,As]=butter(2,2*pi*1000,’s’) that gives
|
| (3.39) |
The arguments of the function butter are the filter order and the cutoff frequency in rad/s (not Hz). Note the required ’s’ to indicate to Matlab/Octave that the goal is to design an analog, not a digital filter.
To obtain Eq. (3.39), one can choose the values and , and then and . In this case, the cutoff frequency would be exactly 1 kHz. But conventional resistors do not have exactly these resistance values. In practice, commercial components are available only within a finite set of values and their actual values differ from the nominal ones, according to a given non-zero tolerance (e. g., 2% or 10%).
Example 3.17. Further examples of analog filter design in Matlab. Listing 3.11 illustrates how to design some analog filters with a given specification for its magnitude using Matlab (this code is not compatible with Octave). The frequency response magnitude and phase of the four designed filters are depicted in Figure 3.21.
1Apass=5; %maximum ripple at passband 2Astop=80; %minimum attenuation at stopband 3%% Lowpass Elliptic %%%%%%%%% 4Fp=100; Wp=2*pi*Fp; %passband frequency 5Fr=120; Wr=2*pi*Fr; %stopband frequency 6[N, Wp] = ellipord(Wp, Wr, Apass, Astop, 's') %find order 7[z,p,k]=ellip(N,Apass,Astop,Wp,'s'); %design filter 8B=k*poly(z); A=poly(p); %convert zero-poles to transfer function 9[H,w]=freqs(B,A); %calculate frequency response 10%% Higpass Elliptic %%%%%%%%% 11Fr=100; Wr=2*pi*Fr; %stopband frequency 12Fp=120; Wp=2*pi*Fp; %passband frequency 13[N, Wp] = ellipord(Wp, Wr, Apass, Astop, 's') %find order 14[z,p,k]=ellip(N,Apass,Astop,Wp,'high','s'); %design filter 15B=k*poly(z); A=poly(p); %convert zero-pole to transfer function 16[H,w]=freqs(B,A); %calculate frequency response 17%% Bandpass Elliptic %%%%%%%% 18Fr1=10; Wr1=2*pi*Fr1; %first stopband frequency 19Fp1=20; Wp1=2*pi*Fp1; %first passband frequency 20Fp2=120; Wp2=2*pi*Fp2; %second passband frequency 21Fr2=140; Wr2=2*pi*Fr2; %second stopband frequency 22[N,Wp]=ellipord([Wp1 Wp2],[Wr1 Wr2],Apass,Astop,'s') %find order 23[z,p,k]=ellip(N,Apass,Astop,Wp,'s');%design filter 24B=k*poly(z); A=poly(p); %convert zero-pole to transfer function 25[H,w]=freqs(B,A); %calculate frequency response 26%% Bandpass Butterworth %%%%%%%%%%% 27[N, Wn]=buttord([Wp1 Wp2],[Wr1 Wr2],Apass,Astop,'s')%find order 28[z,p,k]=butter(N,Wn,'s'); %design Butterworth filter 29B=k*poly(z); A=poly(p); %convert zero-pole to transfer function 30[H,w]=freqs(B,A); %calculate frequency response
It should be noted from Listing 3.11 and Figure 3.21 that a bandpass filter has twice the order that is specified as an input parameter (and obtained by buttord and ellipord in this example). Note also that, in practice, an analog filter typically has an order between 1 to 10. For example, an order is not feasible for practical implementation with an analog circuit.
Example of digital filter design
For comparison, it is interesting to design now an equivalent digital filter to substitute its analog counterpart corresponding to . But in order to interface with the external (analog) world, four extra blocks are required, as illustrated in Figure 3.22. The filters (anti-aliasing) and (external reconstruction) are lowpass analog filters with passband frequency equal to half of the sampling frequency, which is assumed here to be kHz. Their gains are not important at this moment and in practice they are determined by the interfacing electronics. Assuming the converters and analog filters are properly defined, it remains to design , which can be done with the command
that leads to
|
| (3.40) |
It is important to note that when designing an analog filter, the second argument of butter is in rad/s. For a digital filter, as explained in Section 1.8.4, Matlab/Octave uses the normalized frequency . In this case, the Nyquist frequency is 5 kHz and using Eq. (1.39), Hz is normalized by the Nyquist frequency in the command [Bz,Az]=butter(2,(1000/5000)).
It will be later discussed in this chapter that the function butter used the bilinear transformation to convert of Eq. (3.39) into of Eq. (3.40).
From Table 3.1 one knows the definition and this should not be confused with in Eq. (3.40). In many applications is a rational function (a ratio of two polynomials), with specifying the numerator and the denominator. In general, and .
Digital filters described by a rational function can be conveniently implemented via a LCCDE, as discussed next.
Example 3.18. Obtaining the difference equation and implementing a digital filter. For example, assume that a LTI system with impulse response outputs when the input is . In this case, and , which leads to with and . With this concept in mind, Eq. (3.40) can be written as
and taking the Z-inverse one can obtain the difference equation corresponding to Eq. (3.40):
The amazing fact is that this can be implemented with a simple code, similar to Listing 3.12.
1initialization() { %all previous values are assumed 0 2 xnm1=0 %variable to store the value of x[n-1] 3 xnm2=0 %x[n-2] 4 ynm1=0 %y[n-1] 5 ynm2=0 %y[n-2] 6} 7processSample() { 8 xn=readFromADConverter() %read input sample from ADC 9 yn=0.067455*xn + 0.134911*xnm1 + 0.067455*xnm2 + 10 1.14298 ynm1 - 0.41280 *ynm2 11 writeToDAConverter(yn) %write output sample into DAC 12 ynm2=ynm1 %update for next iteration. Note the order of ... 13 ynm1=yn %updates: avoid overwriting a value ... 14 xnm2=xnm1 %that should be used later 15 xnm1=xn 16}
where one assumes a timer13 invokes the function processSample at a rate of (10 kHz in this case).
Figure 3.23 compares the discussed filters, illustrating that has a lowpass frequency response that is similar in terms of passband frequency to the original . For frequencies above the passband, attenuates more than , but this is not deleterious for a lowpass filter. Later, in Section 3.8.4, this behavior will be clarified, which is intrinsic of having the bilinear transformation mapping the behavior of the analog filter at infinite frequencies into rad (or Hz) for , i. e., mapping into .
If is changed, the frequency response of the overall system in Figure 3.22 is scaled according to (Eq. (1.35)). For example, decreasing from 10 to 5 kHz would divide by two the cutoff frequency of the overall system.
3.4.10 Distinct ways of specifying the “ripple” deviation in filter design
As illustrated in Figure 3.21, practical filters have a frequency response that deviates from the ideal ones. Instead of a flat magnitude over the whole passband and zero gain in the stopband, as depicted in Figure 3.8, a non-ideal filter has deviations from the target values and eventual “oscillations” called “ripples”. When designing a filter, it is possible to impose limits to these ripples, but this procedure is different for the passband and stopband “ripples” / deviations, as discussed next.
There are several ways of specifying the maximum “ripple” or deviation at the passband of a filter. For example, it can be specified in dB or linear scale, which are called here and , respectively (as suggested by Matlab). If one assumes a lowpass filter with a unitary gain at DC, the maximum linear deviation can be assumed to be within or . The latter option is particularly useful if the filter magnitude monotonically decreases as for the Butterworth filters and is assumed here, meaning that the frequency response is 1 at DC and decreases in the passband to a value not smaller than . For example, a specification can be that the passband magnitude does not deviate 5% of the gain at DC. In this case, and the minimum magnitude at passband is . Often, this value is specified in dB as
If the deviation is within in linear scale, then it is confined to in dB.
At the stopband, the magnitude in linear scale is also a “deviation” because the reference value is 0 (the desired magnitude at stopband). In other words, for the stopband, the deviation coincides with the magnitude itself and its value in dB is given by
Often, the filter magnitude has a maximum value of 0 dB and the values of and are positive.
Matlab uses the same convention adopted here in its routines. This is exemplified in Listing 3.13, which uses the method buttord to find the order of a Butterworth filter that complies with the project specifications.
1Wp=0.3; %normalized passband frequency (rad / pi) 2Ws=0.7; %normalized stopband frequency (rad / pi) 3Rp=1; %maximum passband ripple in dB 4Rs=40; %minimum stopband attenuation in dB 5[n,Wn] = buttord(Wp,Ws,Rp,Rs); %find the Butterworth order 6[B,A]=butter(n,Wn); %design the Butterworth filter 7zp=exp(1j*pi*Wp); zs=exp(1j*pi*Ws); %Z values at Wp and Ws 8%% Check if the filter obeys requirements 9linearMagWp = abs(polyval(B,zp)/polyval(A,zp)) %mag. at Wp 10linearMagWs = abs(polyval(B,zs)/polyval(A,zs)) %mag. at Ws 11Dp_result = 1-linearMagWp %linear deviation at Wp (linear) 12Rp_result = -20*log10(1-Dp_result) %deviation (ripple) at Wp (dB) 13Ds_result = linearMagWs %linear deviation at Ws (linear) 14Rs_result = -20*log10(Ds_result) %deviation (ripple) at Ws (dB)
The required filter order is n=4, and the obtained results are: linearMagWp=0.9105, linearMagWs=0.01, Dp_result=0.0895, Rp_result=0.8147, Ds_result=0.01 and Rs_result=40.0. They can be interpreted as follows. Matlab designed the method buttord to meet exactly the requirements for the stopband, while giving an eventual slack to the requirements for the passband. Hence, we can see that Rs_result=40.0 dB is exactly the specified attenuation at the stopband. This corresponds to a linear gain linearMagWs=0.01 of the filter’s frequency response at the beginning of the stopband. Using mathematical notation: in linear scale, which corresponds to dB.
The filter gain is 1 at DC, and it decreases until reaching linearMagWp=0.9105 in the end of its passband. In our notation, , which corresponds to dB. This value does not coincide with Rp_result=0.8147 due to the rounding to four decimal places. Using 20*log10(linearMagWp) gives the precise gain value of dB. Note that the deviation in the passband of 0.8147 dB from the ideal 0 dB is within the maximum value of 1 dB imposed to buttord. There is a slack of dB.
In summary, it is a bit confusing how Matlab and other software define the input parameters to functions such as buttord. But one just needs to interpret the ripples in dB as obtained from “deviations” of the ideal values of 1 and 0 in passband and stopband, respectively.
3.4.11 LCCDE digital filters
A digital filter is a discrete-time system that deals with quantized input and output signals (quantized amplitudes). A possible practical scenario for a digital filter is the one shown in Figure 3.22. There are many different kinds of digital filters but this section assumes filters that are based on linear constant-coefficient difference equations (LCCDE). As indicated in Figure 3.1, when zero initial conditions are assumed, the LCCDE systems are a special case of LTI systems. But when one takes in account the non-linear quantization effects that occur in practical CPUs (or digital signal processors) due to their limited precision, the overall system is not strictly LTI. In spite of that, it is convenient to isolate the effects of quantization and finite-precision arithmetics, and study digital filters as LTI LCCDE systems. Later on, the impact of quantizing the filter coefficients and the roundoff errors due to finite-precision can be incorporated. Therefore, hereafter, the term digital filter refers to discrete-time LTI LCCDE systems. Besides, the systems are assumed to be causal.
A system that has the output and input signals related by a LCCDE such as
|
| (3.41) |
can be represented by (taking the Z-transform on both sides of the LCCDE)
In this case, the transfer function is
|
| (3.42) |
which, after eventual algebraic simplifications, can be written as the ratio
|
| (3.43) |
of two polynomials in . Calculating the zeros (roots of the numerator ) and the poles (roots of the denominator ), one can write
where is a gain. The coefficients of Eq. (3.41) can be real or complex. For simplicity, they will be assumed real () unless otherwise stated. In this case, and the roots are real or, for each root , its complex conjugate is also a root such that the product leads to a second-order polynomial with real coefficients.
It is useful to know that the value of at and correspond to the values of the frequency response at (DC) and rad, respectively, which can be written as
|
| (3.44) |
For example has a frequency response with and .
Example 3.19. Specifying a filter in Hz, rad or normalized frequency. When designing digital filters, it is important to remember the fundamental relation , first presented in Eq. (1.35). Figure 3.24 illustrates how this relation can be used to convert a specification for a lowpass analog filter with passband and stopband frequencies of 500 and 850 Hz, respectively, into a specification of a digital filter with , which leads to passband and stopband frequencies of and rad, respectively.
Figure 3.24 also shows the convention used by Matlab/Octave, which gets rid of the irrational number by using a normalized axis , as listed in Table 1.5. In this case, can be written as , which simplifies to obtaining with the normalization of by the Nyquist frequency . For example, Hz in Figure 3.23a turns into in Figure 3.23c. This normalization by the Nyquist frequency is sensible because digital filters are always constrained to work with frequencies of at most Hz, which corresponds to rad.
3.4.12 Advanced: Surface acoustic wave (SAW) and other filters
There are several technologies to build an electronic filter. The options include ceramic, microelectromechanical system (MEMS), yttrium iron garnet (YIG), SAW and many others. Even if the scope is reduced to radio-frequency (RF) communications, the diversity of filters is huge. Consequently, parameters such as the Q-factor, center frequency and insertion loss. This section provides some practical examples.
Example 3.20. Performance of commercial SAW filter. Figure 3.25 illustrates the typical performance of a commercial SAW filter14 with some of its specifications listed in Table 3.5. The insertion gain is shown in Figure 3.25 at 1 and 10 dB per division (div) at the left plot and superimposed (at 1 dB per division) to the group delay at the right plot.
As also indicated in Table 3.5, Figure 3.25 indicates that df1, df3 and df40 are the bandwidths considering the attenuation at 1, 3 and 40 dB, respectively, with values 13.08, 13.88 and 16.6 MHz. The insertion loss at MHz is 24.7 dB. The group delay plot only shows the variation at the order of ns, but Table 3.5 indicates the delay as 1.6 s. is sometimes called IL and Figure 3.25 uses a negative IL to express that the filter attenuates the power by 24.7 dB as properly expressed in Table 3.5.
| Parameter | Minimum | Typical | Maximum |
| Center frequency at C ( or f0, MHz) | 69.8 | 70 | 70.2 |
| Insertion loss at (IL, dB) | - | 24.7 | 28.0 |
| 1-dB bandwidth (df1, MHz) | 12.75 | 13.0 | - |
| 3-dB bandwidth (df3, MHz) | 13.0 | 13.8 | - |
| 40-dB bandwidth (df40, MHz) | - | 16.6 | 17.1 |
| Passband variation (ripple, dB) | - | 0.5 | 0.6 |
| Group delay variation (ns) | - | 25 | 50 |
| Absolute delay (s) | - | 1.6 | - |
The Q-factor of the filter depicted in Figure 3.25 is and provides more than 60 dB of attenuation at the stopband. Building such (relatively) highly-selective filters is easier when the center frequency is fixed than when it has to vary, for tuning purposes. For example, the filter of Figure 3.25 is supposed to operate with MHz, which is an intermediate frequency (IF) used in wireless signal reception. When a receiver has to operate over a frequency range, a common strategy is to pre-select the frequency band of interest using a so-called RF-filter with center frequency (e. g., 2.1 GHz) and convert it via frequency shifting to the IF (e. g., 70 MHz), when it is then better filtered and further processed.
A common IF for broadcast AM radio is kHz, which motivates the next filter example.
Example 3.21. Commercial ceramic filter. Figure 3.26 illustrates the performance of a commercial ceramic filter15 that can be used with an IF of 455 kHz and has some specifications listed in Table 3.6. Note that this filter’s stopband is not flat, especially within the range from 600 to 700 kHz. This makes the specifications harder to interpret than for an ideal bandpass filter.
| Parameter | Value |
| Center frequency (kHz) | |
| Minimum 6-dB bandwidth (kHz) | |
| Maximum stop bandwidth, within 40 dB (kHz) | |
| Minimum stopband attenuation within kHz (dB) | 27 |
| Maximum insertion loss (at minimum loss point, dB) | 6 |
| Maximum ripple within kHz (dB) | 1.5 |
Caution has to be exercised when interpreting the “Maximum stop bandwidth” in Table 3.6, which indicates the filter attenuates 40 dB at the end of a band centered on and with a bandwidth of approximately 30 kHz. But this attenuation then decreases. According to Table 3.6, an attenuation of at least 27 dB is guaranteed only within kHz.
3.4.13 FIR, IIR, AR, MA and ARMA systems
An important characteristic of a digital filter is the duration of its impulse response, which allows to classify it as a finite impulse response (FIR) or infinite impulse response (IIR) filter. For example, a filter with is FIR and a filter with is IIR. Note that if one plots in a computer, due to the limited precision, the values of would underflow to zero for large enough , but theoretically this impulse response has infinite duration.
Another characteristic is whether the filter is recursive or not. A recursive filter has the output depending on past values of the output itself () while the output of a non-recursive filter depends only on the input and its past values (assuming causality). The system function of a non-recursive filter has in Eq. (3.42) and no finite poles.
In practice, FIR can be associated to non-recursive filters and IIR to recursive filters. But recursiveness and impulse response duration are two distinct concepts! It is possible to create a recursive filter with an impulse response of finite duration using cancellation of poles and zeros, for example. In spite of that, the design of recursive filters is often called “IIR design”. Similarly, “FIR design” is the topic that concerns the design of non-recursive filters. This widely adopted jargon is used in this text.
IIR and FIR filters will be discussed in the sequel. While the subject is presented in the context of digital filtering, many conclusions are valid for systems in general. In other words, IIR and FIR systems can be found in applications in which the goal is not filtering, but system identification, equalization, control, tracking, statistics, etc. In some of these areas, is not classified as FIR or IIR, but as MA, AR or ARMA “model”.
A moving-average (MA) model is a non-recursive FIR filter and an autoregressive (AR) filter is a special case of a recursive IIR filter for which in Eq. (3.42). The AR IIR filter does not have finite zeros other than at the origin and is given by
|
| (3.45) |
Note in Eq. (3.45) that the gain value for the numerator is chosen such that the denominator coefficient of Eq. (3.42) is equal to 1. The numerator leads to zeros at and makes causal.
The autoregressive-moving-average (ARMA) model is a generic model composed by an AR (denominator) and MA (numerator) sections. There are many generalizations of these basic models, which are adopted in areas such as statistics. Parametric modeling is the task of, according to a predefined criterion such as least-squares, fit the data to the assumed model. In spite of being defined in distinct scenarios, filter design and parametric modeling share several fundamental results.
Before discussing the design of IIR and FIR filters, it is useful to note the importance of frequency scaling.
3.4.14 Filter frequency scaling
Computational routines often produce a prototype with normalized frequencies (e. g., a cuttof frequency of 1 rad/s) that are then converted (eventually by another routine) to the required frequencies via frequency scaling.
With frequency scaling one can modify a filter to obtain a different cutoff frequency. For example, if has a cutoff of rad/s, the transformation moves this cutoff frequency to rad/s. The operation is similar to using to double the “speed” of a signal represented by , which leads to having half of the support of . Similarly, has twice the support of . More specifically, if the prototype has a cutoff frequency of 1 rad/s, then
|
| (3.46) |
scales the complex plane, and consequently , such that is the cutoff frequency of the new filter .
There are computational routines that provide a prototype filter with (normalized) cutoff frequency of rad/s, which can then be converted to a new filter with an arbitrary cutoff frequency with the transformation . For example, this change in cutoff frequency can be done in Matlab by applying the function lp2lp to a lowpass analog prototype (current version of Octave misses this functionality) as indicated in Listing 3.14.
1N = 5; %filter order 2[B,A] = butter(N,1,'s'); %prototype with cutoff=1 rad/s 3[Bnew,Anew]=lp2lp(B,A,100); %convert to cutoff=100 rad/s 4freqs(Bnew,Anew) %plot mag (linear scale) and phase
Note that lp2lp requires the prototype to have a cutoff frequency of rad/s (besides being an analog lowpass filter).
Example 3.22. Frequency conversion when the prototype does not have a cutoff frequency of 1 rad/s. Assume that a frequency conversion must be applied to such that its cutoff frequency of rad/s is shifted to 30 rad/s. Because this is a simple first-order filter, the final result can be immediately obtained. But the whole procedure is described because it is useful for higher-order filters.
A convenient step is to move the cutoff frequency of to 1 rad/s using a substitution of by , which leads to
Now, the final filter can be obtained by expanding to 30 by substituting in by :
Alternatively, one could directly use . These frequency conversions are widely used in the design of IIR filters as will be discussed.
3.4.15 Filter bandform transformation: Lowpass to highpass, etc.
There are many transformations to convert a prototype (or reference) filter into another one. Section 3.4.14 briefly discussed frequency scaling. It is also possible to convert a lowpass prototype filter into a highpass, bandpass and bandstop, for example, which is called bandform transformation.
When dealing with analog filters, it is often necessary to apply impedance scaling to have the filter input and/or output with a desired impedance. The intent in this case is not to change the transfer function, but to perform impedance matching. All these three kinds of filter transformations are well-discussed in the literature16. In the sequel, bandform transformation is briefly discussed.
Bandform transformations can be used to create a bandpass from a lowpass prototype, for example. These transformations differ considerably for analog and digital frequencies, especially due to the fact that a digital filter has a periodic spectrum.17 Having a lowpass analog prototype, a Matlab user18 can use the functions lp2bp, lp2bs and lp2hp to convert it to bandpass, bandstop and highpass filters, respectively.
Sometimes frequency scaling is incorporated to bandform transformation such that a routine converts a lowpass prototype with normalized 1 rad/s cutoff frequency into another filter with desired bandwidth and frequencies. For example, the Matlab’s function lp2bp converts a normalized lowpass into a bandpass with the desired center frequency and bandwidth as illustrated in Listing 3.15.
1N = 4; %prototype order (bandpass order is 2N = 8) 2[B,A] = butter(N,1,'s'); %prototype with cutoff=1 rad/s 3[Bnew,Anew]=lp2bp(B,A,50,30); %convert to cutoff=50 rad/s 4freqs(Bnew,Anew) %plot mag (linear scale) and phase
The functions lp2bp, lp2bs, lp2hp and lp2lp are restricted to analog filters. Transformations of digital filters can be achieved via a mapping provided by allpass filters, which are filters that have unitary magnitude for all frequencies and just change the phase of the input signal. Besides frequency transformation, allpass filters are adopted for phase equalization and other applications. Some Matlab functions that provide support to digital filter transformations are iirlp2bs, iirlp2bp, iirlp2xn, iirftransf, allpasslp2xn and zpklp2xn.
For example, Listing 3.16 compares the conversion of a Butterworth and a elliptic lowpass prototypes, both with cutoff frequency rad, into stopband versions with cutoff frequencies and rad. The two prototypes are halfband filters because their cutoff frequencies is rad.
1Wc=0.5; %cutoff (normalized) frequency of prototype filter 2Wstop = [0.5 0.8]; %stopband cutoff frequencies 3N=3; %order of prototype filter 4[B,A] = butter(N,Wc); %Butterworth prototype 5[Bnew,Anew]=iirlp2bs(B,A,Wc,Wstop); %Bandstop Butterworth 6[B2, A2] = ellip(N, 3, 30, Wc); %Elliptic prototype 7[Bnew2,Anew2]=iirlp2bs(B2,A2,Wc,Wstop); %Bandstop elliptic 8fvtool(Bnew2, Anew2, Bnew, Anew); %compare freq. responses
For the comparison, it was used the Matlab’s Filter Visualization Tool (fvtool). Note that the fourth argument of ellip is the passband frequency (not necessarily the cutoff frequency). In this case, a maximum ripple of 3 dB was specified using the second argument of ellip to have the passband frequency coinciding with the cutoff frequency Wc ( rad). Besides, a minimum attenuation of dB was required for the stopband of the elliptic lowpass prototype.
As another example, the following Matlab code converts a Butterworth lowpass prototype with cutoff frequency rad into a bandpass with cutoff frequencies and rad.
1N = 5; %filter order 2[B,A] = butter(N,0.5); %prototype with cutoff=0.5 rad 3[Bnew,Anew]=iirlp2xn(B,A,[-0.5 0.5],[0.25 0.75],'pass');
The third and fourth arguments of function iirlp2xn ([-0.5 0.5] and [0.25 0.75]) indicate frequency points in the original filter and to what frequencies they should be mapped. In this case, rad should be mapped to rad and to rad.
Instead of creating a prototype and then converting to the desired filter, most routines allow to directly design the filter. The following commands illustrate the design of highpass, bandpass and bandstop elliptic filters.
1N=5; %filter order for the lowpass prototype (e.g., bandpass is 2*N) 2Rp=0.1; %maximum ripple in passband (dB) 3Rs=30; %minimum attenuation in stopband (dB) 4[B,A]=ellip(N,Rp,Rs,0.4,'high'); %highpass, cutoff=0.4 rad 5[B,A]=ellip(N,Rp,Rs,[0.5 0.8]); %bandpass, BW=[0.5, 0.8], order=2*N 6[B,A]=ellip(N,Rp,Rs,[0.5 0.8],'stop'); %BW=[0.5, 0.8], order=2*N
Similarly, FIR design routines provide support to directly designing filters other than lowpass ones. For example, Listing 3.18 designs a stopband filter. Note the normalization by the Nyquist frequency Fs/2.
1Fs = 44100; %sampling freq. (all freqs. in Hz) 2N = 100; %filter order (N+1 coefficientes) 3Fc1 = 8400; % First cuttof frequency 4Fc2 = 13200; % Second cuttof frequency 5B = fir1(N, [Fc1 Fc2]/(Fs/2), 'stop', hamming(N+1));
Because there are plenty of routines for bandform transformation, the discussion about IIR and FIR filter design concentrates on lowpass filters.
Similar to sampling, the DT/S conversion can now be better understood. After that, the important topic of signal reconstruction is discussed.
