Professional Documents
Culture Documents
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
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.
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