0% found this document useful (0 votes)
3 views

SAS_Lab6_11

Hello bro let me download this I have a exam to study let me download the book bro why are you taking so many details
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

SAS_Lab6_11

Hello bro let me download this I have a exam to study let me download the book bro why are you taking so many details
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

DEPARTMENT OF ECE ECE2003-SIGNALS AND SYSTEMS

Name: Darshan K.V. Branch:ECE Lab Section:B2


Id No:20241ECE3006
Pre-lab Session In-Lab Session Post Lab session Viva (3M) Total Marks 10M
work (2M) work (3M) work (2M)

Remarks:

Date: Signature of the Instructor Marks awarded


Signals and Systems-Lab (ECE2003)
Lab 6: Frequency Analysis: The Continuous Time Fourier
Series (CTFS)
Lab Report
Introduction: A Fourier series is an infinite sum of harmonic functions (sines and
cosines) with every term in the series having a frequency which is an integral multiple of
some “principal” frequency and an amplitude that varies inversely with its frequency. The
usefulness of such series is that any periodic function x t( ) with period T can be written
as a Fourier series as illustrated below.
Basic theory: The basic formulations for Fourier series is illustrated below.
1. Trigonometrical Fourier Series Representation:
Type your text
The trigonometrical Fourier series is represented by

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 .....

 a0an cosn 0t bn sinn0t


n1

where the term a0 is called constant or dc or average value

cos0and sin0t are fundamental frequency components.

cos20t and sin20t are 2nd harmonic components cosn0t

1
DEPARTMENT OF ECE ECE2003-SIGNALS AND SYSTEMS

and sinn0t are nth harmonic components, and an and bn are Fourier Series
coefficients.

Formulas for evaluation of 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

Phase spectrum n  tan1abnn 

2. Exponential Fourier Series:


The exponential Fourier series is represented by

x t( )   ce
n
jn  t
0
n

The exponential Fourier series coefficients cn can be represented in terms of magnitude

c ce c ce c
and phase as n | n | jn and n | n | jn  n* , where * indicate complex

conjugate.

| cn |  12 a bn2 n2  12An, and n  tan1abnn

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

plot(tr,yr,':','LineWidth',2);hold on; % plot truncated trigonometric FS


plot(t,x,'m','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]);
OUTPUT:

Ex7.2: Demo: Complex Exponential Fourier Series representation of a sawtooth wave.


ANS : tr = [-1 0
0 1 1 2 2]; xr = [0 1
0 1 0 1 0]; figure();

4
DEPARTMENT OF ECE ECE2003-SIGNALS AND SYSTEMS

plot(tr,zeros(size(tr)),'k','LineWidth',1); hold on;


plot(zeros(size(tr)),tr,'k','LineWidth',1); hold on; plot(tr,xr,':','LineWidth',3);
xlabel('time (seconds)');ylabel('Amplitude');
title('Original sawtooth signal'); axis([-1 2 -
0.1 1.2]);

% Plot Truncated Fourier Series Approximation (N = 1)


N = 1; % define number of terms to use (n = -N..N)
c0 = 0.5; % define dc bias coefficient t = -1:0.001:2;
% define time values for y(t) y = c0 * ones(size(t)); % let
initial y = c0 (dc bias) for all times for n = -N:-1, %
compute y for negative n cn = exp(j*pi/2)/(2*pi*n); y = y +
real(cn * exp(j*n*2*pi*t));
end;
% compute y for positive n and add to y
for n = 1:N, % found using negative n cn =
exp(j*pi/2)/(2*pi*n); y = y + real(cn * exp(j*n*2*pi*t));
end;

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]);

% Plot Truncated Fourier Series Approximation (N = 2)


N = 2; % define number of terms to use (n = -N..N)
c0 = 0.5; % define dc bias coefficient t = -1:0.001:2;
% define time values for y(t)
y = c0 * ones(size(t)); % let initial y = c0 (dc bias) for all times

for n = -N:-1, % compute y for negative n


cn = exp(j*pi/2)/(2*pi*n); y = y + real(cn *
exp(j*n*2*pi*t));
end;
% compute y for positive n and add to y
for n = 1:N, % found using negative n cn =
exp(j*pi/2)/(2*pi*n); y = y + real(cn * exp(j*n*2*pi*t));
end;

subplot(2,2,2); % plot approximation


plot(tr,zeros(size(tr)),'k','LineWidth',1); hold on;

5
DEPARTMENT OF ECE ECE2003-SIGNALS AND SYSTEMS

plot(zeros(size(tr)),tr,'k','LineWidth',1); hold on;


plot(t,y,'m','LineWidth',2);hold on;
plot(tr,xr,':','LineWidth',1); xlabel('time
(seconds)'); ylabel('y(t) approximation');
title('Truncated FS, N = 2'); axis([-1 2 -0.1
1.2]);
% Plot Truncated Fourier Series Approximation (N = 3)
N = 3; % define number of terms to use (n = -N..N)
c0 = 0.5; % define dc bias coefficient t = -1:0.001:2;
% define time values for y(t) y = c0 * ones(size(t)); % let
initial y = c0 (dc bias) for all times

for n = -N:-1, % compute y for negative n


cn = exp(j*pi/2)/(2*pi*n); y = y + real(cn *
exp(j*n*2*pi*t));
end;
% compute y for positive n and add to y
for n = 1:N, % found using negative n cn =
exp(j*pi/2)/(2*pi*n); y = y + real(cn * exp(j*n*2*pi*t));
end;

subplot(2,2,3); % 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,'k','LineWidth',2);hold on;
plot(tr,xr,':','LineWidth',1); xlabel('time
(seconds)'); ylabel('y(t) approximation'); title('
Truncated FS, N = 3');
axis([-1 2 -0.1 1.2]);
% Plot Truncated Fourier Series Approximation (N = 10) N =
10; % define number of terms to use (n = -N..N) c0
= 0.5; % define dc bias coefficient t = -1:0.001:2;
% define time values for y(t) y = c0 * ones(size(t)); % let initial
y = c0 (dc bias) for all times

OUTPUT:

6
DEPARTMENT OF ECE ECE2003-SIGNALS AND SYSTEMS

Ex7.3: Demo: Complex Exponential Fourier Series representation of a square wave as


well as amplitude and phase spectrum.

7
DEPARTMENT OF ECE ECE2003-SIGNALS AND SYSTEMS

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,':r','LineWidth',3); xlabel('time
(seconds)'); ylabel('Amplitude');
title('Original square wave signal'); axis([-1
3 -1.2 1.2]);
% 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

figure(1) % put first two plots on figure 1

% Compute yce, the Fourier Series in complex exponential form

yce = c0*ones(size(t)); % initialize yce to c0

for n = -N:2:N, % loop over series index n (odd) cn =


2/(j*n*wo); % Fourier Series Coefficient yce = yce +
real(cn*exp(j*n*wo*t)); % Fourier Series computation end
figure(2);
% subplot(2,1,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',1);hold
on;
plot(t,yce,'m','LineWidth',2); % plot truncated exponential FS
xlabel('t (seconds)'); ylabel('y(t)');
ttle=['Truncated Exponential Fourier Series with N = ',num2str(N)]; title(ttle);
axis([-3 3 -1.2 1.2]);
% Draw the amplitude spectrum from exponential Fourier Series
figure(3) % put next plots on figure 3 subplot(2,1,1)
stem(0,c0,'r','fill','LineWidth',2); hold on; % plot c0 at nwo = 0
for n = -N:2:N, % loop over series index n cn =
2/(j*n*wo); % Fourier Series Coefficient
stem(n*wo,abs(cn),'m','fill','LineWidth',2) % plot |cn| vs nwo end
for n = -N+1:2:N-1, % loop over even series index n
cn = 0; % Fourier Series Coefficient
stem(n*wo,abs(cn),'b','fill','LineWidth',2); % plot |cn| vs
nwo end
xlabel('w (rad/s)')
ylabel('|cn|')
ttle = ['Amplitude Spectrum with N = ',num2str(N)]; title(ttle);
grid on

8
DEPARTMENT OF ECE ECE2003-SIGNALS AND SYSTEMS

% Draw the phase spectrum from exponential Fourier Series subplot(2,1,2)


stem(0,angle(c0)*180/pi,'k','fill','LineWidth',2); % plot angle of c0 at nwo = 0 hold
on ;
for n = -N:2:N, % loop over odd series index n
cn = 2/(j*n*wo); % Fourier Series Coefficient
stem(n*wo,angle(cn)*180/pi,'b','fill','LineWidth',2); % plot |cn| vs nwo end
for n = -N+1:2:N-1, % loop over even series index n
cn = 0; % Fourier Series Coefficient
stem(n*wo,angle(cn)*180/pi,'r','fill','LineWidth',2); % plot |cn| vs nwo end
xlabel('w (rad/s)') ylabel('angle(cn)
(degrees)')
ttle = ['Phase Spectrum with N = ',num2str(N)]; title(ttle);
grid;
OUTPUT:

9
DEPARTMENT OF ECE ECE2003-SIGNALS AND SYSTEMS

10
DEPARTMENT OF ECE ECE2003-SIGNALS AND SYSTEMS

Pre lab work:

(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 4nA, nodd
Then the Trigonometrical Fourier Series is represented by

11
DEPARTMENT OF ECE ECE2003-SIGNALS AND SYSTEMS

 1 1 1
x t( )  4A sin 0t 3sin3 0t 5sin5 0t 7

sin7 0t . . . .  
Similarly, the exponential Fourier coefficients are represented by

0, neven
c
n  j A2

 n , nodd
Then the Fourier synthesis is represented by

x t( )      j A52 e j5ω t0  j A32 e j ω t3 0  j A2 e jω t0  j A2 e jω t0

 j A32 e j3ω t0  j A52 e j ω t5 0  

Let A1, T1. 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 A1, T1

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];

< Type the Matlab codes here >

12
DEPARTMENT OF ECE ECE2003-SIGNALS AND SYSTEMS

< Plot the figures and type the results here >

In lab Session Lab:


(a) Execute the Matlab codes prepared for the exercises and observe the results.
(b) Compute all the tasks given in the exercises.
(c) Note the results and store the necessary figures and data for the lab report.

Post Session Lab:


(a) Complete the lab work in all aspects in the given specified lab time.
(b) Answer for the given questions.
(c) Submit the lab report to the lab in-structure and get the signature in time.
(d) Type the complete description of commands used in the lab.

13

You might also like