Exercise 4. Computing and displaying the Fourier Transform of a signal Later in the semester it will become useful to d...
Exercise 4. Computing and displaying the Fourier Transform of a signal Later in the semester it will become useful to determine the frequency response of a signal or system by taking the Fourier Transform empirically (rather than computing it analytically). To do so we make use of the fft and fftshift commands. The fft command is an efficient implementation of the Discrete Fourier Transform (DFT) known as the Fast Fourier Transform (FFT). When the FFT is computed the samples are not ordered properly and thus the fftshift command is called to re-order the samples correctly. Then, to get the magnitude response of the system we again use the abs command (or angle for the phase response) Let's compute the Fourier Transform for a system described by a rectangular function, i.e., take h[nun+10-u[n-11 For reasons that will become clear later, when we create our discrete sequence we pad the sequence with zeros on each side. In MATLAB enter the following commands to define hfn], take the Fourier Transform of it, and then plot the corresponding magnitude response of the systenm n = -100:100; >> h=0*n: h(91:111) = 1; >winspace(-pi, pi,1024 >> H = fftshift ( fft (h, 1024)); >> figure (4); >subplot (2,1,1); >> stem (n,h, ' filled '); >> axis (-100 100 0 1.5]); >> xlabel ( 'SSn$$', 'interpreter ', 'latex '); >title ('SSh [n] S$', 'interpreter', 'latex >> subplot (2,1,2); >> plot (w, abs (H)); >>axis (-pi p 0 25]); >>xlabe 'SomegaSS, 'interpreter ', 'latex ) >title ('SS |H(omega))SS,'nterpreter', atex A few things to note here are that we explicitly specify that the FFT be computed using 1024 points (rather than the default 201 points that is the length of h). This helps to improve the resolution of the frequency response and we will study why that is later in the semester. We create a plotting vector for w to have the same number of samples between [-r and then use the plot command to display the magnitude response, similar to when we plotted the analytic magnitude response in Exercise 3
Exercise 4. Computing and displaying the Fourier Transform of a signal Later in the semester it will become useful to determine the frequency response of a signal or system by taking the Fourier Transform empirically (rather than computing it analytically). To do so we make use of the fft and fftshift commands. The fft command is an efficient implementation of the Discrete Fourier Transform (DFT) known as the Fast Fourier Transform (FFT). When the FFT is computed the samples are not ordered properly and thus the fftshift command is called to re-order the samples correctly. Then, to get the magnitude response of the system we again use the abs command (or angle for the phase response) Let's compute the Fourier Transform for a system described by a rectangular function, i.e., take h[nun+10-u[n-11 For reasons that will become clear later, when we create our discrete sequence we pad the sequence with zeros on each side. In MATLAB enter the following commands to define hfn], take the Fourier Transform of it, and then plot the corresponding magnitude response of the systenm n = -100:100; >> h=0*n: h(91:111) = 1; >winspace(-pi, pi,1024 >> H = fftshift ( fft (h, 1024)); >> figure (4); >subplot (2,1,1); >> stem (n,h, ' filled '); >> axis (-100 100 0 1.5]); >> xlabel ( 'SSn$$', 'interpreter ', 'latex '); >title ('SSh [n] S$', 'interpreter', 'latex >> subplot (2,1,2); >> plot (w, abs (H)); >>axis (-pi p 0 25]); >>xlabe 'SomegaSS, 'interpreter ', 'latex ) >title ('SS |H(omega))SS,'nterpreter', atex A few things to note here are that we explicitly specify that the FFT be computed using 1024 points (rather than the default 201 points that is the length of h). This helps to improve the resolution of the frequency response and we will study why that is later in the semester. We create a plotting vector for w to have the same number of samples between [-r and then use the plot command to display the magnitude response, similar to when we plotted the analytic magnitude response in Exercise 3