
ME2016, Fall 2008, Dr. Ferri
Homework Assignment 10
Due Wednesday, November 19.
Problem 1. (5 points)
This example shows the convergence of a Fourier series, and the relationship between a Fourier
series and a Fast Fourier Transform (FFT). A half-wave rectified sinewave having a frequency
of 1 rad/s and a period of 2π seconds is equal to sin(t) when sin(t) >= 0 and equal to zero when
sin(t) < 0. The Fourier series of such a signal is given by:
"−−−−+= )tcos()tcos()tcos()tsin()t(y 6
35
2
4
15
2
2
3
2
2
11
ππππ
(1.1)
A single period of the periodic signal y(t) can be generated in Matlab using the following two
lines:
» N=128; dt=2*pi/N; T=2*pi; t=0:dt:(T-dt);
» y=sin(t); I=find(y<0); y(I)=zeros(1,length(I));
Note that there are exactly N points, and that N = 128 is a power of 2 ( 2^7). Using powers of 2
for record-lengths of sampled signals is typical in digital signal processing (DSP) because of
computational efficiencies that result in the calculation of FFT’s.
(a) Plot the exact signal as well as the sum of the first two, first three, and first 4 terms in the
Fourier series (2.1) above on the same graph. Be sure to add a legend to identify all curves.
(b) Calculate the FFT of y by typing » Y = fft(y); Plot abs(Y) versus the frequency vector
w, showing the full range of frequencies. Next, make a separate plot of abs(Y) vs w,
focusing on the frequency range of 1 to 10 rad/s. On this latter plot, show the individual
points as small circles ‘o’, connected by dotted lines. Add a grid. Note that, even though Y
is complex-valued, its magnitude is given by abs(Y). Also note that the fundamental
frequency w0, is equal to 1 rad/s since w0 = 2*pi/T = 1 in this case. The 1xN frequency
vector w is given by the Matlab command
» w0 = 2*pi/T; w = w0*(0:(N-1)); % freq vector in rad/s
(c) At what frequencies does the FFT show peaks? Does this match the predictions from the
Fourier series? How do the amplitudes of those peaks compare with the Fourier-series
coefficients shown in Equation 1.1?
Solution
The solution for part (a) is shown in Figure 1.1. The Fourier series converges nicely to the exact
function.