4. (36 marks) Discrete Fourier transform (DFT) by fast Fourier transform (FFT)
a. Generate a 5-cycle 10 Hz sine signal with an amplitude of 1 at a sampling rate of 500 Hz.
i. What is the total number of samples in this discrete-time signal? (1 mark)
ii. Perform an N-point DFT of this signal by directly calculating the equation. Choose a proper N.(10 marks)
iii. Now, perform FFT of this signal using the built-in ‘fft’ function with the same N and compare the computation speed of FFT and DFT in (i). Which one is faster?(4 marks)
iv. Add random noise to the sine signal in the time domain and plot the noisy signal (Hint: built-in ‘randn’ function; you can self define a standard deviation to contaminate the original signal with larger or smaller random noise). (5 marks)
v. Perform FFT of the noisy signal in iv). Plot the amplitude spectrum of this noisy signal. Observe the spectrum, compare it with the amplitude spectrum obtained in iii), and briefly describe any obvious difference between the two spectra. (6 marks)
b. Filter the noisy signal with a commonly used one—Butterworth filter. (Hint: built-in ‘buttord’ to estimate the filter order and cut off frequency, ‘butter’ to obtain the filter coefficients, and then ‘filter’ to filter the signal.) Then, plot the original and filtered signals in the same figure using built-in ‘hold on’ function. Are you able to successfully filter the random noise? (10 marks)