You are on page 1of 5

ECE 2111 Signals and Systems

Spring 2009, UMD


Experiment 5: Fourier Series
Consider the continuous time signal given by
y(t) = A0 + A1 cos (2 f0 t + 1 ) + A2 cos (4 f0 t + 2 ) + A3 cos (6 f0 t + 3 )
where A0 is the DC component of the signal, Ak are the amplitude of the harmonics, k is
the harmonic number, and k are the phase angle of the harmonics. The expression for a
Fourier Series representation of a function signal x(t) with N harmonics is

The features of a signal given by this equation can be studied in terms of the
frequency, amplitudes, and phases of the sinusoidal terms. The amplitudes A1, A2, A3, . . ,
An specify the relative weights of the frequency components of the particular signal.
These weights are a major factor in determining the shape of the signal. The phase angle
of a trigonometric component controls the position of the component along the time axis.
In the first part of the experiment you will investigate the effect of the magnitude and
phase angle components. You will be asked to change the amplitude and phase values and
compare the resulting waveform to the original one.
Part 1. Harmonic Components of Periodic Signals
Consider that signal
y(t) = A0 + A1 cos (2 f0 t + 1 ) + A2 cos (4 f0 t + 2 ) + A3 cos (6 f0 t + 3 )
with period of T0 = 0.1 sec and the component values given in the following Table

a) Enter the following MATLAB code in an M-file to show the harmonic


components and waveforms synthesized by using 2 and 3 harmonic components.
Hint:

To open an M-file you have to go to File menu in the command prompt page and select
New M-file. Then the M-file editor will show up. After writing your program save it to a
location and memorize it.
Now to use your program in the command prompt page first you have to specify the
location your program is located and you can do so by typing the following:
cd C:\ Documents and Settings\ece\desktop\the only place to save
After typing that you type your program name on the screen and it will be executed.
f0=10; % Define the period of the signal
t = 0:0.001:0.1;
harm1 = cos(2*pi*10*t);
harm2 = 2*cos(2*pi*20*t+45/180*pi);
signa2 = harm1 + harm2;
harm3 = 1*cos(2*pi*30*t+60/180*pi);
signa3 = signa2 + harm3
figure(1)
subplot(2,3,1); plot(t,harm1)
subplot(2,3,2); plot(t,harm2)
subplot(2,3,3); plot(t,harm3)
subplot(2,3,4); plot(t,signa2)
subplot(2,3,5); plot(t,signa3)
Now you will study the importance of the magnitude and phase angle of these
components by changing them and comparing the resulting waveform to the original one.
Changing the magnitude of the harmonics
b) Change the magnitude of the second harmonic from A2 = 2 to A2 = 1 by reducing it in a
step of 0.2. Modify the MATLAB script of a) in accordance to the change, and resynthesize the waveforms. Describe what changes where made in the shapes of the
waveforms.
Changing phase of the harmonics
c) Change the phase angle of the second harmonic from 2 = 45o to 2 = 10o by reducing it
in a step of 5o. Change the MATLAB script of a) in accordance to the change, and resynthesize the waveforms. Describe what changes where made in the shapes of the
waveforms.
Adding an harmonic to the signal y(t)
d) Using the original waveform with the three harmonics given in Table 1, create another
waveform by adding a 4th harmonic with a magnitude of 1.5 and a phase angle of 120o.
Plot the results and compare the shapes with the original signal.
Part 2. Magnitude Spectra and the partial Fourier Series
In this part of the experiment you will compute and plot the magnitude spectrum and the
partial Fourier series sums of two periodic signals: a square wave, and a triangular wave.

a) Magnitude Spectrum of a Square Wave


The following MATLAB script defines an odd square wave (period 1 sec, no DC level, 2
Vpp) using the M-file.
% Program to give partial Fourier sums of an
% odd square wave of 2 Vpp amplitude
n_max = input('Enter vector of highest harmonic values
desired (odd):');
f = 1;
N = n_max; %length(n_max);
t = 0:0.002:1;
omega_0 = 2*pi*f;
x=zeros(size(t));
n=1:1:N;
b_n=zeros(size(n));
for i=1:(N+1)/2;
k=2*i-1;
b_n(k)=4/(pi*k);
% This part is for plotting the Magnitude spectrum
figure(1)
subplot((N+1)/2,1,i);
stem(b_n),xlabel('Integer Multiple of Fundemental
Frequency');
ylabel('Amplitude'),grid;
x=x+b_n(k)*sin(omega_0*k*t);
% This part is for plotting the partial Fourier sum
figure(2)
subplot((N+1)/2,1,i),plot(t,x),xlabel('t'),ylabel('partial
sum');
axis([0 1 -1.5 1.5]),text(0.05,-0.5,
['max.har.=',num2str(k)]);
grid;
end
The Fourier series components for this signal is a summation of odd harmonics of the
sine wave with a magnitude of 4/(k) , where k is the harmonic number. Using MATLAB
compute the magnitude of the harmonics coefficients, this is, b 1, b2, b3, b4,, bn. Plot the
amplitude spectrum (line spectrum) of the square wave and Plot the partial Fourier sums
starting from 1 harmonic till 15 harmonics. Write down your conclusions.

b) Magnitude Spectrum of a triangular Wave


The Fourier series components for this signal is a summation of the harmonics of the
cosine wave with a magnitude of -8/(2k2) , where k is the harmonic number. Using

MATLAB compute the magnitude of the harmonics coefficients, this is, a1, a2, a3, a4,,
an. Plot the amplitude spectrum (line spectrum) of the square wave and Plot the partial
Fourier sums starting from 1 harmonic till 15 harmonics. Write down your conclusions.
The following MATLAB script defines a triangular wave (period 1 sec, no DC level, 2
Vpp) using the M-file.
% Program to give partial Fourier sums of a
% Triangular wave of 2 Vpp amplitude
n_max = input('Enter vector of highest harmonic values
desired (odd):');
f = 1;
N = n_max; %length(n_max)
t = 0:0.002:1;
omega_0 = 2*pi*f;
x=zeros(size(t));
n=1:1:N
a_n=zeros(size(n));
for i=1:(N+1)/2;
k=2*i-1;
a_n(k)=-8/(pi^2*k*k)
% This part is for plotting the Magnitude spectrum
figure(1)
subplot((N+1)/2,1,i);
stem(a_n),xlabel('Integer Multiple of Fundemental
Frequency');
ylabel('Amplitude'),grid;
x=x+a_n(k)*cos(omega_0*k*t);
% This part is for plotting the partial Fourier sum
figure(2)
subplot((N+1)/2,1,i),plot(t,x),xlabel('t'),ylabel('partial
sum');
axis([0 1 -1.5 1.5]),text(0.05,-0.5,
['max.har.=',num2str(k)]),grid;
end

Post Experiment (Report) Requirements:


1- Every student must have his own individual lab report.
2- The report should include the following:

a) Results with detailed explanations are needed.


b) Answer the questions if there are any.
c) Conclusion - what did you learn in this experiment? Please write only a few
lines.
3- All reports should be word processed and should also have the assigned cover
page.

You might also like