I need help with this matlab coding question, Fourier Series Matlab.
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 thus fun must be defined using array operators. For examples, instead of using the operator **? for multiplication, one would use :*? Consider the function æ(t) = =e * (ln(t)) In Matlab the above becomes fun = O(t) exp(-t. 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 X(t)dt 10 5." 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 series in exponential form. The coefficients Ck can be calculated using 1 Ck = Huileje x(t)e-jkwot dt. The sinusoid x(t) = sin(wt) with a frequency of 100 Hz is passed through an ideal full-wave rectifier. Calculate the magni- tude of the coefficients |ck|, 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 |ck| against k. 1
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 response in the passband. The transfer function of such a Butterworth filter with gain Go can be written as N 1 H(s) = = Go II (2) S-Pk k=1 = where n is the order of the filter and pk are the poles of the filter. The transfer function shown is normalized to a cutoff frequency we of 1 rad/s and the resulting filter is called a lowpass prototype. Matlab provides the function buttap() for computing the zeros (z), poles (p) and gain (k) of the transfer function (2). For a Butterworth filter of order n e Z+, the function buttap can be called as follows: [z, p, k] buttap(n) The coefficients of the numerator and denominator polynomials of (2) can then be obtained using the Matlab function zp2tf(): [b, a] = zp2tfſz, p, k) where b is an array for the coefficients in the numerator and a is an array for the coefficients in the denominator. 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 poles and their locations? The frequency response of the filter can obtained using freqs(). The documentation for freqs() 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 wc. The cutoff frequency can be changed in Matlab using the function Ip2lp() which can be used as follows: [bt, at] = 1p2lp(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 lp2lp() 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 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 (jw) is given by Y(jw) = X(jw)H(jw) = (3) where X(jw) is the input signal spectrum and H(jw) is the frequency response of the filter. For the k-th harmonic of the rectified sinusoid X(jkwo) = Ck = (4) where wo is the fundamental angular frequency of the rectified wave. Therefore, at the k-th harmonic = Y(jkwo) = X(jkwo) H(jkwo) Y(jkwo) = CkH(jkwo) Design a lowpass Butterworth filter that reduces the magnitude of the second harmonic by at least a factor of 103. 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 wo 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 achieves these objectives.
I need help with this matlab coding question, Fourier Series Matlab.
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am