CS代考 Chapter 7 Filtering

Chapter 7 Filtering
In Topics 3 and 4 we saw how to compute the response of DT and CT LTI systems in the time domain using convolution. In this Chapter we see how to compute the response of LTI systems to periodic inputs using a frequency domain approach. It turns out that all we need to do is multiply the Fourier series coefficients of the input by the frequency response evaluated at an appropriate frequency. In other words, LTI systems just multiply each frequency component by a different number, a process we think of as filtering the frequencies in the input.
This gives us an alternative to the convolution formula to find the output of an LTI system. Perhaps more importantly, it provides a new way to think about designing LTI systems. Very often we want to design systems that suppress certain unwanted frequency components, and enhance desired frequency components. As an example, in speech systems, the signal of interest usually consists of frequency components at frequencies smaller than 4000Hz. Any higher fre- quencies are typically unwanted signals (noise, interference, etc) in the system. We can suppress noise by designing a system that filters out high frequencies, and keeps low frequencies. We can specify an LTI system that achieves this by designing a system with a desired frequency response.
In Section 7.1 we show how we can use the frequency response to determine the output of an LTI system when the input is periodic. In Section 7.2 we then discuss some basic approaches to designing LTI systems that have a desired frequency response. We consider both ideal filters, and the design of more practical filters using MATLAB.

Copyright By PowCoder代写 加微信 powcoder

7.1 Response of LTI systems to periodic inputs
We have seen that the frequency response tells us how an LTI system responds when the input is a complex exponential. In this section we study how an LTI system responds to a general periodic signal. To do this, we first decompose a periodic signal as a sum of scaled complex exponentials (using Fourier series). The response of the system to each of these components can be predicted using the frequency response. The response of the system to the overall input is then the sum of the scaled responses to each of the frequency components, because the system is linear.
Suppose S is a CT LTI system with frequency response H, and x(t) is periodic with period
T0 = 2π . Then x(t) has a Fourier series decomposition as ω0
x(t) = 􏰉 Xkejkω0t k=−∞

and the output y of the system when the input is x is
y(t) = 􏰉 XkH(kω0)ejkω0t. k=−∞
In other words, the Fourier coefficients Yk of the output are related to the Fourier coeffi- cients of the input via
Yk = H(kω0)Xk for all integers k.
The key point here is that if we know the Fourier coefficients Xk of the input, and the frequency response H(ω) of the system, we can find the Fourier coefficients Yk of the output by just performing multiplication. This is potentially much simpler than using the convolution formula.
• If the frequency response at frequency kω0 is zero, then that frequency component, that was present in the input, is removed or filtered from the output. This is the basis for frequency selective filtering, which we discuss in the next section.
• There are no new frequency components in the output that were not already present in the input. This is a consequence of the system being linear.
Essentially the same result holds for DT LTI systems.
Suppose S is a DT LTI system with frequency response H, and x[n] is periodic with period N0 = 2π . Then x[n] has a Fourier series decomposition as
x[n] = 􏰉 Xkejkω0n
and the output y of the system when the input is x is
y[n] = 􏰉 XkH(kω0)ejkω0n.
In other words, the Fourier coefficients Yk of the output are related to the Fourier coeffi- cients of the input via
Yk = H(kω0)Xk for all integers k.
Summary of Section 7.1
If the input to an LTI system is a periodic signal then the kth Fourier series coefficient of the output is the product of the kth Fourier series coefficient of the input and H(kω0), the frequency response at frequency kω0.
7.2 Frequency selective filtering
Linear time-invariant systems that are designed to pass some frequency components and signifi- cantly reduce the magnitude of (or completely eliminate) other frequency components are called frequency selective filters. In this section we first introduce ideal frequency selective filters, and then present some basic practical filter design methods based on MATLAB that approximate ideal filters.

7.2.1 Ideal filters in continuous time
Ideal frequency selective filters have a range of frequencies that are ‘passed’ (the passband) and a range of frequencies that are ‘stopped’ (the stopband). The frequency response is exactly one for frequencies in the passband. The frequency response is exactly zero for frequencies in the stopband. Depending on where the passband and the stopband are located we use different names for these ideal filters.
Ideal lowpass filter
An ideal lowpass filter has a passband centred around the zero frequency. It passes low fre- quencies and stops high frequencies. The cutoff frequency is the frequency at the transition between the passband and the stopband. The frequency response is
􏰀1 if|ω|≤ωc HLP(ω) = 0 if |ω| > ωc.
Note that the frequency response is symmetric about zero. This ensures that the corre- sponding LTI system is a real system and that the complex exponential ejωt is filtered in the same way as the complex exponential e−jωt.
Ideal bandpass filter
An ideal bandpass filter has a passband centred in a ‘band’ between ωc1 and ωc2 (and between their negatives). The stopband includes low frequencies (between −ωc1 and ωc1) and high frequencies (greater that ωc2 and less than −ωc2).

Ideal highpass filter
An ideal highpass filter has a stopband centred at zero frequency (so it stops low frequen- cies) and passes all frequencies above the cutoff frequency ωc.
In Topic 8 we will see how to compute the impulse responses of ideal filters such as these using the inverse Fourier transform. For now, the main thing to note is that all of these filters turn out to be non-causal. In other words, to compute the filter output at time t, we need to know the input signal at future times. This is one of the main reasons these are called ‘ideal’ filters, since they are not practical to implement. Nevertheless, they are very useful conceptually!
7.2.2 Ideal filters in discrete-time
Similar to the continuous-time situation, we can define ideal frequency-selective filters in discrete- time. The most important difference between continuous-time and discrete-time ideal filters is that in discrete-time the frequency response must have period 2π. The frequency response of lowpass, bandpass, and highpass discrete-time ideal filters are shown below. Notice that two periods are shown. To see just one period, focus only on frequencies between −π and π rad/sample.
−2π−2π+ωc −π −ωc0ωc HBP(ω)
−2π −π −ωc2 −ωc1 0 ωc1 ωc2 4

ω −2π −2π+ωc −π −ωc 0 ωc π 2π−ωc 2π
Notice that
• the ‘low’ frequencies are those near zero and those near any integer multiple of 2π;
• the ‘high’ frequencies are those near π rad/sample and any odd integer multiple of π. This is because π rad/sample is the maximum frequency in discrete-time and the frequency response must have period 2π.
7.3 FIR filter design in MATLAB
Recall that the simplest discrete-time LTI systems are those with finite impulse response. In this section we briefly discuss how to use MATLAB to design frequency selective filters by choosing the coefficients of the impulse response of an FIR filter to meet desired specifications on the frequency response.
We will adopt the convention that the impulse response of an FIR filter is only non-zero at timesn=0,1,…,L−1whereListhelength ofthefilterandL−1istheorder ofthefilter. This will ensure that our filter is causal. In this case, the output y and the input x are related by
y[n] = h[0]x[n] + h[1]x[n − 1] + · · · h[L − 1]x[n − (L − 1)] for all n.
This is just the convolution formula specialized to the case when h[n] = 0 for n ≤ −1 and n ≥ L.
Much research effort has gone into the problem of designing filters that satisfy, as well as possible, given frequency domain specifications. MATLAB has numerous filter design methods included as built-in functions in the signal processing toolbox. In this unit we discuss how to use just one of these functions firpm, and do not explain how it works. Our aim is not to give an exhaustive treatment of filter design, but to provide an entrance to using filter design tools.
Using firpm
The function firpm (so-named because it uses the Parks-McClellan algorithm), in its simplest
form, is used with the following syntax
h = firpm(L-1, F, A);
Summary of Section 7.2
One natural way to design LTI systems is to specify their frequency response. The simplest way we might do this is to ask for a system that ‘passes’ some frequencies and ‘stops’ others. Such systems are called ideal frequency selective filters.

The output h contains the non-zero coefficients of the impulse response. It is a vector of length L such that h(1) corresponds to h[0], h(2) corresponds to h[1], etc. This is because MATLAB indexes from 1 rather than 0. The function firpm has three inputs. The first is the filter order (which is the length minus one). The second and third arguments are vectors that specify the desired magnitude of the frequency response. We will show how these work with the following example of FIR filter design.
Lowpass FIR filter design
To design a lowpass filter with firpm we specify a passband and a stopband. Unlike for an ideal filter, there is another band, between the passband and the stopband, called the transition band, where we don’t care what the frequency response looks like. This allows for a more gradual transition between passband and stopband. Suppose we want to pass all frequencies below 0.125π rad/sample, and stop all frequencies above 0.25π rad/sec. The ‘picture’ of the desired magnitude of the frequency response we have in mind is then
ω −π −π −π 0 π π π
where the passband and stopbands are showed with the thick black lines, and the transition band is indicated in grey. We specify this in MATLAB by specifying vectors
F = [0,0.125,0.25,1];
A = [1,1,0,0];
Note that when we specify F we omit the factors of π!
If we want to use firpm to design a length 8 FIR filter with passband −0.125π ≤ ω ≤
0.125π and stopband 0.25π ≤ ω ≤ π and −π ≤ ω ≤ −0.25π we run the following code h = firpm(7,[0,0.125,0.25,1],[1,1,0,0]);
The magnitude of the frequency response of this filter can be calculated and plotted in MATLAB using the following code
omega = [-pi:pi/250:pi];
H = zeros(1,length(omega));
for ii=1:length(h)
H = H + h(ii)*exp(-sqrt(-1)*omega*(ii-1));
plot(omega,abs(H));

Below we have plotted this frequency response compared with the specification we gave the algorithm.
Note how the designed response is not quite one in the passband, and is not quite zero in the stopband. This is because we designed a relatively low-order filter.
We can repeat our design with a longer (higher order) filter by running
h = firpm(63,[0,0.125,0.25,1],[1,1,0,0]);
This produces a length 64 filter. The magnitude of the frequency response is now
This is clearly a much better approximation of the ideal frequency response characteristics we asked for. But achieve this better approximation we needed to use a longer filter. This has two potential issues
• We need to do more computation to find a single output of the filter. • The filter introduces more delay (we discuss this next).
Phase and delay
The filters produced by firpm have the property that they have linear phase. We can see what this means by plotting the phase of the length 8 filter designed above. We plot the unwrapped phase. This means that instead of the phase jumping from −π to π when H(ω) crosses the negative real axis from below, we allow the phase to keep decreasing.

∠H(ω) 2.5π
We can make a similar plot of the unwrapped phase of the length 64 filter designed above. In this case the slope in the passband is much steeper.
−π π −2.5π
In the first case, the phase response is linear in the passband, i.e., ∠H(ω) = −(7/2)ω for −0.125π ≤ ω ≤ 0.125π.
In the second case, the phase response is linear in the passband, but a different linear function: ∠H(ω) = −(63/2)ω for −0.125π ≤ ω ≤ 0.125π.
In general, if firpm produces a filter of length L it has the property that ∠H(ω)=−((L−1)/2)ω for−ωc ≤ω≤ωc
where ωc is the boundary of the specified passband. These are linear functions of the frequency, hence these filters are said to have linear phase.
Notice that firpm always produces real impulse response coefficients. That means that if the input to the system is x[n] = cos(ωn) then the output is
y[n] = |H(ω)| cos(ωn + ∠H(ω)). 8

If the phase is linear in the passband, and of the form ∠H(ω) = −((L − 1)/2)ω for ω in the passband, then
y[n] = |H(ω)| cos(ω(n − (L − 1)/2))
for ω in the passband. The effect of a filter of length L produced by firpm is to delay sinusoidal inputs in the passband by (L − 1)/2 samples. This means that the longer the filter is, the more delay it introduces, which may be a problem if the filter is running in real-time.
IIR filters
We have only talked about designing FIR filters using MATLAB in this section. There are also MATLAB-based tools to design IIR filters with desired frequency response. In this case, MATLAB produces the coefficients of a linear, constant coefficient difference equation
a0y[n] + a1y[n − 1] + · · · + aN y[n − N] = b0x[n] + b1x[n − 1] + · · · + bM x[n − M] that specifies the filter.
Summary of Section 7.3
We can design finite impulse response (FIR) and infinite impulse response (IIR) discrete- time filters in MATLAB. For FIR filters we do this by specifying a passband and a stopband and an ‘order’ for the filter. The result approximates an ideal filter as well as possible for a given order.
7.4 Summary
LTI systems act ‘independently’ on each of the frequency components of a signal, multiplying each by the value of the frequency response at that frequency. We found that if Xk are the Fourier series coefficients of a periodic signal with fundamental period ω0, then the Fourier coefficients of the output are Yk = H(kω0)Xk. This gives a very easy way to find a frequency- domain description of the output of an LTI system when we are given a frequency-domain description of a (periodic) input.
The frequency response doesn’t just give us a way to analyse systems. It also provides a useful way for us to specify design parameters for LTI systems. Often we want to design LTI systems that suppress certain frequencies and pass others. These are frequency selective filters. Ideal frequency selective filters have frequency responses that are 1 for the frequencies we want to pass, and 0 for the frequencies we want to stop. These are useful conceptually, but give rise to non-causal systems and so are not always practical. Nevertheless, there are well- developed computational methods to design filters based on frequency domain specifications. We discussed one such MATLAB function, that designs discrete-time finite impulse response LTI systems given a desired frequency domain description.
In this chapter we only discussed the output of an LTI system when the input was periodic. For this we needed the Fourier series decomposition of the periodic input signal. In the next chapter we describe how to use the frequency response to find the output of an LTI system for a general aperiodic input. This relies on a generalization of the Fourier series to aperiodic signals. This is called the Fourier transform, and is the subject of the next Topic.

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com