L5 - Fourier Series (During Lecture)
L5 - Fourier Series (During Lecture)
L5 - Fourier Series (During Lecture)
Faculty of Engineering
Department of Electrical and Electronics Engineering
1 1
Z
T <∑
c0 = x (t) dt ≈ ∆t x (t) (1)
T <T > T>
In other words, we “extract” the differential dt as a constant from the integral, divide it by
the fundamental period, and multiply this result by the sum of all values within the vector
xa , containing the information of a period of the signal x (t). A similar approximation can
be made for the Exponential Fourier Series coefficients. Recall that these coefficients can be
computed via the analysis equation by
1 1
Z
T <∑
c̄k = x (t) e− jkω0 t dt ≈ ∆t x (t) e− jkω0 t (2)
T <T > T>
In this case, the inner summation ∑<T > x (t) e− jkω0 t must be evaluated for each value of k of
interest. For example, if we are interested in computing the coefficient c̄3 (k = 3), then we
have to calculate the sum
1
T <∑
∆t x (t) e− j3ω0 t
T>
for loops can be useful when multiple harmonics are requested. The following piece of code
illustrates this procedure for computing 3 harmonics. Notice that we assume that the signal
x (t) has already been computed within the program, and its fundamental period T0 has been
declared.
1 %Assume x is a vector containing exactly one period of the signal
2 % coefficients will be computed up to the third harmonic
3 index =1;
4 for k = -3:3
5 % Notice that this expression is also valid for k =0
6 c( index )= dt * sum (x .* exp ( -1 i*k *2* pi *t/ T0 ))/ T0 ;
7 % Or equivalently : c( index )= mean (x .* exp ( -1 i* k *2* pi *t/ T0 ));
8 index = index +1;
9 end
10 % c =[ c_m3 c_m2 c_m1 c_0 c_1 c_2 c_3 ]
11 % index = 1 2 3 4 5 6 7
a Notice that the left-hand part of equation 1 is the exact definition of the mean value, while the right-hand part is
nothing but a Riemann sum divided by T.
2π
with ω0 = T0 = 2π f 0 . Assume f 0 = 60 Hz
a) Plot the signal x (t) for 10 periods. Use a time interval of ∆t = 1001 f (Hint: con-
0
struct a plot with three subplots. The two remaining spaces will be used in part e)
of this exercise)
b) Compute the DC level of the signal (Hint: since the signal is constructed in ten
periods, divide the approximation of the integral by ten to obtain the exact result)
c) Determine the value of the following Exponential Fourier Series (EFS) coeffi-
cients and fill the table:
k c̄k
-3
-2
-1
0
1
2
3
d) Repeat the previous exercise for f 0 = 120 Hz. Compare your results and conclude.
k c̄k
-3
-2
-1
0
1
2
3
e) In the second and third subplots, graph the magnitude and the phase of the first
5 EFS harmonics (both positive and negative: −5 ≤ n ≤ 5), respectively. How can
you describe the magnitude and phase spectra?
d) Plot the original signal and each of its Fourier Series approximations, place in
the title of each plot the corresponding sumation of the absolute approximation
error alongside the number of computed coefficients. Superimpose the plots of
the original signal and its approximation. (Hint: generate a 2 × 2 subplot –e.g.,
subplot(2,2,1)- and graph the superimposed signals x (t) and its approximation
x̃ (t) in each case. )