Filters 1 Fourier Series 1.1 Numerical Integration Numerical integration refers to methods or algorithms for computing t
Posted: Tue Apr 26, 2022 2:56 pm
Filters 1 Fourier Series 1.1 Numerical Integration Numerical integration refers to methods or algorithms for computing the approximate numerical value of a definite integral. Matlab provides several functions for numerical integration. One such function is integral() which has the following syntax: integral(fun, xmin, xmax) where fun is a special variable called a handle to a function that represents the integrand. The values xmin and xmax are the lower and upper limits of the integral. The functions of interest in this lab are scalar-valued and the fun must be defined using array operators. For examples, instead of using the operator *** for multiplication, one would use. Consider the function r(t) = *(In(t)) In Matlab the above becomes fun = m(t) exp(-+ 2)." (log(t)). 2 where the multiplication and power operators are prefixed with dots which mean they can operate on arrays. Moreover, this function definition is a so-called anonymous function which is a function that is not saved in its own Matlab m-file but is instead associated with the handle fun, in our example. The operator signals the creation of a function handle, which is followed by the input argument x in parentheses and then the mathematical operations that define the function. The integral ſztat can be calculated numerically by calling integral(fun, 0, 10) The function fun can also be parameterized. Refer to the Matlab documentation for the function integral() for examples of parameterized functions 1.2 Discrete Spectrum from Fourier Series The discrete spectrum of a periodic signal can be obtained from the coefficients of the Fourier scrics in exponential form. The coefficients can be calculated using a = 310) (t)est. (1) The situsoid (t) = sin(t) with a frequency of 1 kHz is passed through an ideal full-wave rectifier. Calculate the magnitude of the coefficients cal for -5 <k < 5, of the Fourier series in exponential form for the rectified wave. Use the Matlab stem() function to plot the discrete spectrum of the rectified wave, i.e. plot lay against
2 Analogue Filters 2.1 Butterworth Filter The Butterworth approximation of an ideal filter is a type of analogue filter that is said to have a maximally flat magnitude respouse in the passband. The transfer function of such a Butterworth filter with gain G, can be written as H(s) = GII (2) PR where n is the order of the filter and px are the poles of the filter. The transfer function shown is normalized to a cutoff frequency e of 1 rad/s and the resulting filter is called a lowpass prototype. Matlab provides the function buttap() for computing the zeros(2), poles (p) and gain (k) of the transfer function (2). For a Butterworth filter of order n € Z , the function buttap can be called as follows: [2, p. k] = buttap(n) The coefficients of the numerator and denominator polynomials of (2) can then be obtained using the Matlab function zp2tf(): [b, al = zp2tf(z. p. k) where is an array for the coefficients in the numerator and a is an array for the coefficients in the denominntor. The transfer function can then be constructed by H = tf(b, a) Experiment with these functions to create Butterworth filter prototypes of various order. Plot the poles and zeros of the transfer function using pzmap(). From these experiments, what can be deduced about the number of pokes and their locations? The frequency response of the filter can obtained using freqs(). The documentation for fregs() provides examples of how it can be used to plot the frequency response magnitude and phase. The lowpass prototype can be turned into or transformed into other types of filters. The lowpass prototype with cutoff of 1 rad/s can be transformed into a lowpass filter with arbitrary cutoff we. The cutoff frequency can be changed in Matlab using the function 1p24p() which can be used as follows: [bt, at] = 1p2ip(b, a, wc) where (b. a) are the polynomial coefficients of the lowpass prototype, wc is the desired cutoff frequency in rad/s and (bt, at) are the polynomials coefficients of the transformed filter. Exper- iment with the p2ip() function: plot the frequency response of the prototype and transformed filter on the same axes and verify the desired cutoff frequency is achieved. 2
2.2 Filtering a Rectified Sinusoid The output of the full-wave rectifier from Section 1.2 is to be filtered by a lowpass Butterworth filter. In the frequency domain, the output of the filter Y Gw) is given by Y(jw) = X(jw)H() (3) where XGw) is the input signal spectrum and HGw) is the frequency response of the filter. For the k-th harmonic of the rectified simusoid XGkun) where an is the fundamental angular frequency of the rectified wave. Therefore, at the k-th harmonic y (kw) = x (kwa jkun) ykus) = 1 Gun) Design a lowpass Butterworth filter that reduces the magnitude of the second harmonic by at least a factor of 10'. The order of the filter should be as small as possible. The filter should affect the magnitude of the fundamental as little as possible, i.e. the loss at frequency should be minimised. Calculate the magnitude response of the filter at the chosen cutoff frequency The magnitude response at angular frequency wc given a transfer function Q can be computed in Matlab by abs(freqresp(Q. wc)) Present suitable evidence in the form of calculations and plots to support the claim that the designed filter achieve these objectives. 3
2 Analogue Filters 2.1 Butterworth Filter The Butterworth approximation of an ideal filter is a type of analogue filter that is said to have a maximally flat magnitude respouse in the passband. The transfer function of such a Butterworth filter with gain G, can be written as H(s) = GII (2) PR where n is the order of the filter and px are the poles of the filter. The transfer function shown is normalized to a cutoff frequency e of 1 rad/s and the resulting filter is called a lowpass prototype. Matlab provides the function buttap() for computing the zeros(2), poles (p) and gain (k) of the transfer function (2). For a Butterworth filter of order n € Z , the function buttap can be called as follows: [2, p. k] = buttap(n) The coefficients of the numerator and denominator polynomials of (2) can then be obtained using the Matlab function zp2tf(): [b, al = zp2tf(z. p. k) where is an array for the coefficients in the numerator and a is an array for the coefficients in the denominntor. The transfer function can then be constructed by H = tf(b, a) Experiment with these functions to create Butterworth filter prototypes of various order. Plot the poles and zeros of the transfer function using pzmap(). From these experiments, what can be deduced about the number of pokes and their locations? The frequency response of the filter can obtained using freqs(). The documentation for fregs() provides examples of how it can be used to plot the frequency response magnitude and phase. The lowpass prototype can be turned into or transformed into other types of filters. The lowpass prototype with cutoff of 1 rad/s can be transformed into a lowpass filter with arbitrary cutoff we. The cutoff frequency can be changed in Matlab using the function 1p24p() which can be used as follows: [bt, at] = 1p2ip(b, a, wc) where (b. a) are the polynomial coefficients of the lowpass prototype, wc is the desired cutoff frequency in rad/s and (bt, at) are the polynomials coefficients of the transformed filter. Exper- iment with the p2ip() function: plot the frequency response of the prototype and transformed filter on the same axes and verify the desired cutoff frequency is achieved. 2
2.2 Filtering a Rectified Sinusoid The output of the full-wave rectifier from Section 1.2 is to be filtered by a lowpass Butterworth filter. In the frequency domain, the output of the filter Y Gw) is given by Y(jw) = X(jw)H() (3) where XGw) is the input signal spectrum and HGw) is the frequency response of the filter. For the k-th harmonic of the rectified simusoid XGkun) where an is the fundamental angular frequency of the rectified wave. Therefore, at the k-th harmonic y (kw) = x (kwa jkun) ykus) = 1 Gun) Design a lowpass Butterworth filter that reduces the magnitude of the second harmonic by at least a factor of 10'. The order of the filter should be as small as possible. The filter should affect the magnitude of the fundamental as little as possible, i.e. the loss at frequency should be minimised. Calculate the magnitude response of the filter at the chosen cutoff frequency The magnitude response at angular frequency wc given a transfer function Q can be computed in Matlab by abs(freqresp(Q. wc)) Present suitable evidence in the form of calculations and plots to support the claim that the designed filter achieve these objectives. 3