Starting from:

$30

BIOENG1320 Biological Signals and Systems MATLAB Project 3 -Solved


Computing the Fourier Transform of a biological signal: The Fourier Transform is perhaps the 
most popular technique for analyzing biological signals. It allows the signals to be visualized in 
the frequency domain via spectra. From Lecture, the Fourier Transform is given as follows: 
𝑋(πœ”) = ∫−∞∞ π‘₯(𝑑)𝑒−π‘—πœ”π‘‘π‘‘π‘‘. 
(1) 
In general, the biological signal π‘₯(𝑑) is too complicated to determine its Fourier Transform 𝑋(πœ”) 
analytically (i.e., by pencil and paper). A computer must therefore be used. However, the Fourier 
Transform is a continuous function and an infinite integral. As a result, it cannot be determined 
with a computer! Three modifications are necessary for computer-based solution. First, the 
integral is approximated using rectangular pulses of width 𝑇𝑠 to convert it to a sum as follows: 
𝑋(πœ”) ≈ ∑∞𝑛=−∞ π‘₯(𝑛 𝑇𝑠)𝑒−π‘—πœ”π‘‡π‘ π‘›π‘‡π‘ . 
(2) 
Then, the signal is assumed to be non-zero within the finite time interval [0, (𝑁 − 1)𝑇𝑠 + 𝑇𝑠] so 
that the infinite sum becomes a finite sum as follows: 
𝑋(πœ”) = ∑𝑁𝑛=−01 π‘₯(𝑛 𝑇𝑠)𝑒−π‘—πœ”π‘‡π‘ π‘›π‘‡π‘ . 
(3) 
Finally, the continuous variable πœ”π‘‡π‘  is sampled at intervals of 2π‘πœ‹ over the range of [0,2πœ‹] to 
transform the continuous function to a discrete function as follows: 
𝑋[π‘˜] = 𝑋(πœ”)|πœ”π‘‡π‘ =2π‘πœ‹π‘˜ = ∑𝑁𝑛=−01 π‘₯(𝑛 𝑇𝑠)𝑒−𝑗2π‘πœ‹ π‘˜π‘›π‘‡π‘ , 
π‘˜ = 0,1, … , 𝑁 − 1. 
(4) 
For convenience, 𝑇𝑠 is set to unity to arrive at the “Discrete Fourier Transform (DFT)” as follows: 
𝑋[π‘˜] = ∑𝑁𝑛=−01 π‘₯[𝑛]𝑒−𝑗2π‘πœ‹ π‘˜π‘› , 
π‘˜ = 0,1, … , 𝑁 − 1.
 (5) 
The DFT is a discrete function and a finite sum. As a result, it is amenable to computer-based 
solution for a given “sampled signal” π‘₯[𝑛]. 
The Fast Fourier Transform (FFT) is a family of algorithms for efficient computation of the DFT. 
These algorithms, in particular, are widely used in biological signal processing.2 
The purpose of this problem is to learn how to use the all-important, built-in fft function. 
1. Figure 1 shows a continuous-time signal π‘₯(𝑑). The Fourier Transform of this signal can be 
determined analytically and is 𝑋(πœ”) = 12 ( 𝑠𝑖𝑛(6πœ”) 
6πœ” )2 𝑒−π‘—πœ”12 . Plot the magnitude and phase 
spectra over an πœ” range of [0, πœ‹] using a fine sampling interval.
 This exact result will be 
needed to compare the FFT results to be computed below. 
Figure 1 
2. Take samples of π‘₯(𝑑) at 𝑇𝑠 = 1 to define π‘₯[𝑛] as a vector of 25 samples in length using the 
triang function. Use the fft function to compute the DFT of this signal for 𝑁 = 256. Plot the 
DFT magnitude and phase spectra. Note that the x-axis should range over an πœ”π‘‡π‘  of [0,2πœ‹]. 
How does this result compare to the analytical result? What is the highest frequency shown 
by the FFT? 
3. Now plot the DFT spectra of the signal for 𝑁 = 16, 32, 128. Compare all FFT plots with the 
analytical result. For what values of 𝑁 are the DFT samples (mostly) valid? Which values of 
𝑁 are, for the most part, indicative of the true spectral content of the signal and why? How 
can 𝑁 be chosen in practice without knowledge of the analytical result? 
4. Use pair 17 in Table 7.1 (Fourier Transform pairs) and properties in Table 7.2 (Fourier 
Transform properties) to derive 𝑋(πœ”) in question 1. (Hint: see Practice Exam 1!) 
5. Compute the DFT for the clean action potentialsignal from Project 1. Plot the DFT magnitude 
and phase spectra. Note that 𝑇
𝑠 = 

in the previous questions. This simplification turned out 
to make frequencies for π‘₯(𝑑) and 
π‘₯
[𝑛
] the same values! However, in general, 𝑇𝑠 is not unity. 
For example, 𝑇𝑠 = 0.0796 ms for the action potentialsignal. So,such simplification no longer 
holds. From the red font, it can be inferred that the highest frequency shown by the FFT in 
units of Hz is half the “sampling frequency” (i.e., 1/(2*0.0796)=6.2814 kHz in this case). So, 
make sure to plot the spectra from 0 kHz to 6.2814 kHz! Do the spectra meet your 
expectations for the action potential signal?Designing a filter to remove noise from a biological signal: In Project 1, a filter impulse response 
was given, which removed the noise in the noisy action potential signal without compromising 
the information in the clean action potentialsignal. In practice, filters are not given! The purpose 
of this problem is to learn how to design a filter. 
6. Plot the DFT magnitude and phase spectra for the noisy action potential signal from Project 
1. Compare to the corresponding plots of the clean action potential signal. This comparison 
may be facilitated using units of decibels. What are the main differences in the frequency
domain? Noting these differences should help in filter design. 
7. Now design a filter using window-based filter design to selectively remove the noise. Use the 
built-in function fir1. Apply the filter to each signal while experimenting with different cutoff 
frequencies. Plot the selected filter impulse response and each of the filtered signals. What 
kind of filter was selected and what were the cutoff frequencies? 

More products