Unknown
XXXXXXXXXXEGR324L: Linear Systems and Signals La
XXXXXXXXXXLab 3: Fourier Series
Objective
To gain understanding of Fourier series representation and approximation of continuous time periodic signals.
Background
Fourier Series
We have learnt in class that with few exception, commonly encountered periodic signals can be represented as the weighted sum of harmonically related sinusoids:
where
is in general a complex constant. Note that T = 2π/ω0.
In this exercise, the Fourier series for a number of continuous-time, periodic signals is first computed. We will then plot the approximation of these continuous-time signals obtained by linear combination of finite number of harmonically related sinusoids, using Fourier series as their weights (coefficients).
Note that the equation to obtain Fourier series must be found "by hand", because symbolic integration involved cannot be done by Matlab.
Matla
Please read the Matlab book or the on-line help for the following topics:
· function subplot( mnp) -- plot in a split graphical window
· if statement and else statement
· function zeros
Development
( I ) Write a M atlab function a = sq_wave( N), where a is a vector containing Fourier series [ a-N a-N+1 ... a-1 ao a1 ... aN-1 aN ] for the square wave shown in Fig. I.
(I)
Fig. 1 Square wave
(2) Write a Matlab function a = saw_wave(N), where a is a vector containing Fourier series [ a-N a-N+1 ... a-1 ao a1 ... aN-1 aN ] for the saw waveform shown in Fig. 2.
Fig. 2 Saw waveform
(3) Write a Matlab function a = half_rect(N), where a is a vector containing Fourier series [ a-N a-N+1 ... a-1 ao a1 ... aN-1 aN ] for the waveform generated by a half wave rectifier as shown in Fig. 3.
Fig. 3 Waveform generated by a half wave rectifie
(
(
4
)
)
(4) Write a Matlab function [x , t] =fs_approx( a, ω0, tmin, tmax, n). It is assumed that vector a = [ a-N a-N+1 ... a-1 ao a1 ... aN-1 aN ]. Vector x contains n samples of the Fourier series approximation
etween t = tmin (sec) and t = tmax (sec). Note that parameter ω0 is the angular frequency of the original periodic signal from which Fourier coefficients in a were derived. Output vector t, to be used for plotting, contains time reference for co
esponding elements in x.
Your program should check whether input vector a is of size 2N + 1 for some N ≥ 0. It should also check whether tmax > fmin. Empty vectors, i.e., x = [] and t = [] should be returned if input parameters are not valid.
Experiment
(0A) Write a function trainplot( ox, vx), which takes a column vector vx as input, and plots it as shown in Fig. 4. Parameter ox is the smallest n such that x[n] is non zero.
Fig 4. Plot generated by trainplot for vector <-3, [1, 2, -1, 0, -1]
( 1A) Plot imag( sq_wave(19)) and imag( sq_wave(39 )) using function trainplot developed in part (0A)
What can you say about the real part of the Fourier series, and why?
(1B) Using functions sq_wave and fs_approx, compute and plot approximations x5( t), x19( t), x79( t) for at least one period, say for tmin = -0.5Ď€ to tmax = 1.8Ď€.
Examine the minimum and maximum values for each approximation xN( t). What can you conclude from the observation?
(2A) Using function trainplot, plot real and imaginary part of ak obtained with saw_wave(19). Use Matlab function subplot so that then two plots can be shown in the same graphic window.
(2B) Using functions saw_wave and fs_approx, plot x5(t), x20(t) and x80(t) for at least one period. Note that for better presentation, you may want to compute and plot the approximations for tmin = -0.2 to tmax = 1.2.
(3A) Compute and plot real( half_rect( 20)) using function trainplot. What can you say about the imaginary part of the Fourier series, and why?
(3B) Using functions half_rect and fs_approx, compute and plot x5(t), x10(t), x20(t) and
x40(t) for at least one period, say from fmin = -12 (ms) to fmax = 12 (ms).
Report
(1) Turn-in all Matlab work, including all .m files.
(2) Turn-in all the graphical plots.
(3) Discuss the results of this experiment.
(4) For each problem, describe your approach, including all the work done by hand.
(5) Make comments for each experiment, and answer questions.