SAS_Lab6_11
SAS_Lab6_11
Remarks:
a a a a
x t( ) 0 1cos 0t 2 cos2 0t 3 cos3 0t .....
b b b
1sin 0t 2 sin2 0t 3sin3 0t .....
1
DEPARTMENT OF ECE ECE2003-SIGNALS AND SYSTEMS
and sinn0t are nth harmonic components, and an and bn are Fourier Series
coefficients.
a
n T
1
0
T
x t dt( ) ,
a
n T
2
0
T
x t( )cosn 0t dtT and
0 0 b
n
2T
x t( )sinn t dt
Fourier Spectrum:
2 2
The magnitude spectrum An a bn n , and
x t( ) ce
n
jn t
0
n
c ce c ce c
and phase as n | n | jn and n | n | jn n* , where * indicate complex
conjugate.
Examples:
Ex7.1: Demo: Trigonometrical Fourier Series representation of a square wave.
ANS : tr = [-3 -2 -2 -1 -1 0 0 1 1 2 2 3]; yr = [-1 -1 1 1 -1 -1 1 1 -1 -1 1 1];
figure(1); plot(tr,zeros(size(tr)),'k','LineWidth',1); hold on;
plot(zeros(size(tr)),tr,'k','LineWidth',1); hold on; plot(tr,yr,':b','LineWidth',3);
xlabel('time (seconds)'); ylabel('Amplitude');
title('Original square wave signal'); axis([-1
3 -1.2 1.2]);
2
DEPARTMENT OF ECE ECE2003-SIGNALS AND SYSTEMS
% Parameters
N = 11; % summation limit (use N odd)
wo = pi; % fundamental frequency (rad/s)
c0 = 0; % dc bias
t = -3:0.01:3; % declare time values
N = 1;
x = c0*ones(size(t)); % initialize yt to c0 for n = 1:2:N,
% loop over series index n (odd) cn = 2/(j*n*wo); % Fourier
Series Coefficient x = x + 2*abs(cn)*cos(n*wo*t+angle(cn)); % Fourier
Series computation end
figure(2); subplot(2,2,1)
plot(tr,zeros(size(tr)),'k','LineWidth',1); hold on;
plot(zeros(size(tr)),tr,'k','LineWidth',1); hold on;
plot(tr,yr,':','LineWidth',2);hold on; % plot truncated trigonometric FS
plot(t,x,'k','LineWidth',2); xlabel('t (seconds)'); ylabel('y(t)'); ttle = ['Trig.
Fourier Series with N = ',num2str(N)]; title(ttle);axis([-3 3 -1.2 1.2]); N
= 5;
x = c0*ones(size(t)); % initialize yt to c0 for n = 1:2:N,
% loop over series index n (odd) cn = 2/(j*n*wo); % Fourier
Series Coefficient x = x + 2*abs(cn)*cos(n*wo*t+angle(cn)); % Fourier
Series computation end subplot(2,2,2)
plot(tr,zeros(size(tr)),'k','LineWidth',1); hold on;
plot(zeros(size(tr)),tr,'k','LineWidth',1); hold on;
plot(tr,yr,':','LineWidth',2);hold on; % plot truncated trigonometric FS
plot(t,x,'b','LineWidth',2); xlabel('t (seconds)'); ylabel('y(t)'); ttle = ['Trig.
Fourier Series with N = ',num2str(N)];
title(ttle);axis([-3 3 -1.2 1.2]); N
= 11;
x = c0*ones(size(t)); % initialize yt to c0 for n = 1:2:N,
% loop over series index n (odd) cn = 2/(j*n*wo); % Fourier
Series Coefficient x = x + 2*abs(cn)*cos(n*wo*t+angle(cn)); % Fourier
Series computation end subplot(2,2,3)
plot(tr,zeros(size(tr)),'k','LineWidth',1); hold on;
plot(zeros(size(tr)),tr,'k','LineWidth',1); hold on;
plot(tr,yr,':','LineWidth',2);hold on; % plot truncated trigonometric FS
plot(t,x,'r','LineWidth',2); xlabel('t (seconds)'); ylabel('y(t)'); ttle = ['Trig.
Fourier Series with N = ',num2str(N)];
title(ttle);axis([-3 3 -1.2 1.2]); N
= 21;
x = c0*ones(size(t)); % initialize yt to c0 for n = 1:2:N,
% loop over series index n (odd) cn = 2/(j*n*wo); % Fourier
Series Coefficient x = x + 2*abs(cn)*cos(n*wo*t+angle(cn)); % Fourier
Series computation end
subplot(2,2,4) plot(tr,zeros(size(tr)),'k','LineWidth',1);
hold on; plot(zeros(size(tr)),tr,'k','LineWidth',1); hold
on;
3
DEPARTMENT OF ECE ECE2003-SIGNALS AND SYSTEMS
4
DEPARTMENT OF ECE ECE2003-SIGNALS AND SYSTEMS
figure();
subplot(2,2,1); % plot approximation
plot(tr,zeros(size(tr)),'k','LineWidth',1); hold on;
plot(zeros(size(tr)),tr,'k','LineWidth',1); hold on;
plot(t,y,'r','LineWidth',2); hold on;
plot(tr,xr,':','LineWidth',1); xlabel('time
(seconds)'); ylabel('y(t) approximation');
title('Truncated FS, N = 1'); axis([-1 2 -0.1
1.2]);
5
DEPARTMENT OF ECE ECE2003-SIGNALS AND SYSTEMS
OUTPUT:
6
DEPARTMENT OF ECE ECE2003-SIGNALS AND SYSTEMS
7
DEPARTMENT OF ECE ECE2003-SIGNALS AND SYSTEMS
8
DEPARTMENT OF ECE ECE2003-SIGNALS AND SYSTEMS
9
DEPARTMENT OF ECE ECE2003-SIGNALS AND SYSTEMS
10
DEPARTMENT OF ECE ECE2003-SIGNALS AND SYSTEMS
(a) Study and understand the basic theory required for this lab.
(b) Run the Matlab scripts given for examples and study the results.
(c) Perform the analytical solutions for the given laboratory exercises.
(d) Prepare the Matlab codes for the given laboratory exercises well before the
commencement of lab scheduled time. Discuss with your lab instructors.
Lab Exercise-7
Exercise 7.1: Consider a periodic square wave (odd signal) shown below.
Justify that the trigonometrical and exponential Fourier series are represented as below.
Trigonometrical Fourier Series Coefficients: The mathematical equations for given
signal can be written as
T
x t( ) A,0T2 tt 2T
A,
The given signal is odd signal and have rotational symmetry. That is x( ) t x t( )
and x t( T2) x t( ). Therefore the Fourier series coefficients consists only odd
harmonics.
a0 0, an 0, bn 4nA, nodd
Then the Trigonometrical Fourier Series is represented by
11
DEPARTMENT OF ECE ECE2003-SIGNALS AND SYSTEMS
1 1 1
x t( ) 4A sin 0t 3sin3 0t 5sin5 0t 7
sin7 0t . . . .
Similarly, the exponential Fourier coefficients are represented by
0, neven
c
n j A2
n , nodd
Then the Fourier synthesis is represented by
Let A1, T1. Develop Matlab code to determine and plot the magnitude and phase
spectrum for the number of coefficients N 1, N 5, N 13, both in trigonometrical and
exponential Fourier series.
Exercise 7.2: Develop Matlab code to determine and plot the magnitude and phase
spectrum for the various number of coefficients, both in trigonometrical and exponential
Fourier series for the following continuous time periodic signals. Assume A1, T1
Hint: Fig (a) is an even signal, where as Fig(b) is an odd signal. The Matlab code for
generation of the above signals are as follows Fig(a): An even signal:
tr = [-3 -2, -1, 0, 1, 2, 3, 4 5];
xr = [-1 1, -1, 1,-1, 1,-1, 1,-1];
Fig(a): An odd signal
tr = [-3,-2.5,-2,-1.5,-1,-0.5,0, 0.5,1, 1.5,2, 2.5,3];
xr = [ 0,-1, 0, 1, 0,-1, 0, 1, 0, -1, 0, 1, 0];
12
DEPARTMENT OF ECE ECE2003-SIGNALS AND SYSTEMS
< Plot the figures and type the results here >
13