Signal Processing and MATLABTM
1: Fourier Series and Fourier Transform:
• Define the time variable t in Matlab as ‘t=linspace(-pi*6,pi*6,6000)’, and generate three sine waves according to the equation
where the parameter a is an arbitrary number of your choice. Plot the three sine waves against time superimposed in one figure, assigning each curve a different colour of your choice. What are the periods of the three sine waves respectively? Comment on the effect of the parameter n on the frequency of the sine wave.
• Discuss the use of Fourier Series and Fourier Transform representations.
• Use the following Matlab code to plot f(t).
The time series f(t) is a sequence of square waves. Find the 3rd and the 25th order Fourier Series approximation of f(t) using the equation given in slide 9 of the lecture note. The Matlab code is provided in the same slide, with slight modification needed to change the number of iterations in each case. Plot each approximation superimposed with the original signal. Discuss the effect of the order of the Fourier Series on the accuracy of the approximation for f(t).
2: Power Spectral Density:
Download a data file called ‘data.mat’ from the folder ‘Lab 5 – Signal processing’ on Blackboard. Save it to your Matlab work directory. Then load this data file into Matlab using the Matlab command:
This data file contains two variables: the time variable t (in seconds) and the data variable y (in milli-volt) which contains measurements from an electrophysiological experiment.
• _Plot the measurement y in time. You will see a sharp negative deflection around t=0. Paste this figure to your answer sheet. Now in order to reveal the dynamic characteristics of this deflection, zoom into the figure so that the variable y is displayed approximately in the time range [0 0.05]. Paste this figure to your answer sheet. What is the approximate time at which the negative peak occurred?
• Using the first two values of the time variable t to calculate the sampling frequency.
• Estimate the PSD of the variable y using ‘fft’ and plot the PSD vs frequency. (Hint: The frequency range should be calculated from freq=sample_freq*(0:L/2)/L, where sample_freq is the sampling frequency you have calculated previously, and L is the data length.) You should see a spike near the zero frequency but nothing at higher frequencies. Paste this figure to your answer sheet. Zoom into the figure so that the PSD is displayed approximately in the frequency range [0 250] Hz. Paste this figure to your answer sheet.
• A spike should be observed in the PSD at 50Hz. Explain what the spike might represent.
3: Filter Design:
The same data file from question 2 is used for this question. (Paste all figures to your answer sheet.)
In order to obtain the low frequency component of the signal as well as to eliminate the high frequency noise, a Butterworth lowpass filter is required with a cut off frequency at 500Hz. Design and apply this filter to the signal y, using a 1st and a 4th Butterworth filter respectively. In each case,
• superimpose the original and the filtered signal. Zoom in the data to a time scale of 10ms (avoid 0~100ms), and discuss the effect of the order of the filter on the quality of the filtered data.
• Calculate the frequency response of the original and the filtered data, and superimpose them in a figure. Zoom into the frequency range of 895~915Hz, and discuss why there is a difference between these frequency responses.