0% found this document useful (0 votes)
96 views9 pages

Lab Report No. 10: Signals& Systems EEE-223

The document is a lab report that includes 4 tasks: 1. Plotting the approximation of a signal using 81 terms of the Fourier series. 2. Plotting the Fourier coefficients of a periodic signal. 3. Plotting the approximation of a square wave signal using 41 and 201 terms and their coefficients. 4. Calculating the approximation percentage of a signal using 3, 5, 7, and 17 terms and plotting each approximation.

Uploaded by

Tayyab Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
96 views9 pages

Lab Report No. 10: Signals& Systems EEE-223

The document is a lab report that includes 4 tasks: 1. Plotting the approximation of a signal using 81 terms of the Fourier series. 2. Plotting the Fourier coefficients of a periodic signal. 3. Plotting the approximation of a square wave signal using 41 and 201 terms and their coefficients. 4. Calculating the approximation percentage of a signal using 3, 5, 7, and 17 terms and plotting each approximation.

Uploaded by

Tayyab Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Page |1

Signals& Systems
EEE-223

Lab Report No. 10

Name
Tayyab Ahmad

Registration Number
FA18-BEE-154

Class
BEE-4C

Instructor’s Name
Ma’am Nida Zamir
Page |2

Lab 10- Trigonometric (Real) Fourier series Representation


and its Properties
In-Lab Tasks
t
Task 01: The periodic signal x (t ) is defined in one period as x(t )  te ,0  t  6 . Plot
approximate signal using 81 terms of trigonometric form of Fourier series.

Code Result
clear all
% Expressing variables
T0=0;
T=6;
w=2*pi/T;
syms t
x=t*exp(-t); Approximation with 81 terms

0.35
a0=(1/T)*int(x,t,T0,T0+T);
% Finding bn 0.3
for n=1:80
0.25
b(n)=(2/T)*int(x*cos(n*w*t),t,T0,T0+T);
end 0.2

% Finding cn 0.15
for n=1:80
0.1
c(n)=(2/T)*int(x*sin(n*w*t),t,T0,T0+T);
end 0.05
k=1:80;
xx=a0+sum(b.*cos(k*w*t))
0 1 2 3 4 5 6
+sum(c.*sin(k*w*t));

fplot(xx,[T0 T0+T])
title('Approximation with 81 terms')
Page |3

Task 02: Plot the coefficients of the trigonometric Fourier series for the periodic signal that
2
t
in one period is defined by x(t )  e ,  3  t  3 .

Code Result
clear all
close all

% Expressing variables
T = 6;
0.3
T0 = -3;
w = 2*pi/T; 0.2

0.1
syms t
0
x = exp(-t.^2); -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
k = 1:10;
a = (1/T)*int(x,t,T0,T0+T); 0.4

b =
(2/T)*int(x*cos(k*w*t),t,T0,T0+T) 0.2

;
c = 0
1 2 3 4 5 6 7 8 9 10
(2/T)*int(x*sin(k*w*t),t,T0,T0+T) 10
-41

; 4

% Plotting the coefficients 0

subplot(3,1,1) -2
stem(0,a) 1 2 3 4 5 6 7 8 9 10
subplot(3,1,2)
stem(k,b)
subplot(3,1,3)
stem(k,c)

Task 03: The periodic signal x (t ) in a period is given by


1, 0  t  1
x(t )  
0, 1  t  2
Plot in one period the approximate signals using 41 and 201 term of the trigonometric
Fourier series. Furthermore, each time plot the complex exponential coefficients.
Page |4

Code Result
clear all
close all

% Expressing variables
T0 = 0; Aprox. with 41 terms
T = 2;
w = 2*pi/T; 1

syms t 0.9

x=heaviside(t)-heaviside(t-1); 0.8

k=1:40; 0.7

a0 = (1/T)*int(x,t,T0,T0+T); 0.6
b = 0.5
(2/T)*int(x*cos(k*w*t),t,T0,T0+T);
0.4
c =
0.3
(2/T)*int(x*sin(k*w*t),t,T0,T0+T);
% 41 terms 0.2

for n = 1:40 0.1

b(n) = 0

(2/T)*int(x*cos(n*w*t),t,T0,T0+T);
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
%#ok<*SAGROW>
end
for n = 1:40
c(n) =
(2/T)*int(x*sin(n*w*t),t,T0,T0+T);
end
k = 1:40;
xx = a0 + sum(b.*cos(k*w*t)) +
sum(c.*sin(k*w*t));
fplot(xx, [T0 T0+T]);
title('Aprox. with 41 terms')
a0 41Terms
0.6
%coefficients for 41 terms
0.4

subplot(3,1,1) 0.2

stem(0,a0) 0
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1

title('a0 41Terms') b1 41Terms


1
subplot(3,1,2)
stem(k,b) 0

title('b1 41Terms')
subplot(3,1,3) -1
0 5 10 15 20 25 30 35 40
stem(k,c) c1 41Terms

title('c1 41Terms') 0.6

0.4

0.2

%Approximation using 201 terms 0


0 5 10 15 20 25 30 35 40
for n=1:200
Page |5

b(n)=(2/T)*int(x*cos(n*w*t),t,T0,T0+T
);
end Approximation with 201 terms

for n=1:200 1

0.9

c(n)=(2/T)*int(x*sin(n*w*t),t,T0,T0+T 0.8

); 0.7

end 0.6

k=1:200; 0.5
xx=a0+sum(b.*cos(k*w*t)) 0.4
+sum(c.*sin(k*w*t));
0.3

0.2
fplot(xx,[T0 T0+T])
title('Approximation with 201 terms') 0.1

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2

Task 04: The periodic signal x (t ) in a period is given by


 1, 0  t 1
x(t )  
2  t , 1  t  2
Calculate the approximation percentage when the signal x (t ) is approximated by 3, 5, 7,
and 17 terms of the trigonometric Fourier series. Furthermore, plot the signal in each case.
Page |6

Code Result
clear all;
close all;
% Expressing variables

T0 = 0; Approximation with 3 terms


T = 2;
w = 2*pi/T; 1

syms t 0.9
x = heaviside(t)+
((heaviside(t-1)).*(1- 0.8

t)); 0.7
k = 1:2;
a0 = 0.6

(1/T)*int(x,t,T0,T0+T) 0.5

;
b = 0.4

(2/T)*int(x*cos(k*w*t) 0.3

,t,T0,T0+T);
c = 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2

(2/T)*int(x*sin(k*w*t)
,t,T0,T0+T);

for n = 1:2
b(n) =
(2/T)*int(x*cos(n*w*t)
,t,T0,T0+T);
%#ok<*SAGROW>
c(n) = a0 for 3 Terms
(2/T)*int(x*sin(n*w*t)
0.6
,t,T0,T0+T); 0.4
end 0.2

0
xx1 = a0 + -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1

b1 for 3 Terms
sum(b.*cos(k*w*t)) + 0

sum(c.*sin(k*w*t));
fplot(xx1, [T0 T0+T]); -0.1

title('Approximation
-0.2
with 3 terms') 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2

c1 for 3 Terms
0.3
%coefficients for 3
0.2
terms
0.1

subplot(3,1,1) 0
1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2

stem(0,a0)
title('a0 for 3
Terms')
subplot(3,1,2)
Page |7

stem(k,b)
title('b1 for 3
Terms')
subplot(3,1,3)
stem(k,c) Approximation with 5 terms
title('c1 for 3
Terms') 1

0.9

0.8

0.7

%Approximation using 5 0.6

terms 0.5

s 0.4
for n = 1:4
b(n) = 0.3

(2/T)*int(x*cos(n*w*t) 0.2

,t,T0,T0+T); 0.1

c(n) = 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2

(2/T)*int(x*sin(n*w*t)
,t,T0,T0+T);
end
xx1 = a0 +
sum(b.*cos(k*w*t)) + a0 for 5 Terms
sum(c.*sin(k*w*t)); 0.6
fplot(xx1, [T0 T0+T]); 0.4
title('Approximation 0.2
with 5 terms') 0
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1

b1 for 5 Terms
0

%coefficients for 5
terms -0.1

subplot(3,1,1) -0.2
1 1.5 2 2.5 3 3.5 4

stem(0,a0) c1 for 5 Terms

title('a0 for 5 0.3

Terms') 0.2

subplot(3,1,2) 0.1

stem(k,b) 0
title('b1 for 5 1 1.5 2 2.5 3 3.5 4

Terms')
subplot(3,1,3)
stem(k,c)
title('c1 for 5
Terms')

%Approximation using 7
terms

for n = 1:6
Page |8

b(n) = Approximation with 7 terms


(2/T)*int(x*cos(n*w*t)
,t,T0,T0+T); 1

c(n) = 0.9
(2/T)*int(x*sin(n*w*t)
0.8
,t,T0,T0+T);
end 0.7

k = 1:6; 0.6
xx1 = a0 +
0.5
sum(b.*cos(k*w*t)) +
sum(c.*sin(k*w*t)); 0.4

fplot(xx1, [T0 T0+T]); 0.3


title('Approximation
0.2
with 7 terms')
0.1

%coefficients for 7 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2

terms

subplot(3,1,1) a0 for 7 Terms


stem(0,a0)
0.6
title('a0 for 7 0.4
Terms') 0.2
subplot(3,1,2) 0

stem(k,b) -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1

b1 for 7 Terms
title('b1 for 7 0

Terms')
-0.1
subplot(3,1,3)
stem(k,c) -0.2

title('c1 for 7 1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 6

c1 for 7 Terms
Terms') 0.3

0.2

0.1

0
1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 6

%Approximation using
17 terms

for n = 1:16
b(n) =
(2/T)*int(x*cos(n*w*t)
,t,T0,T0+T);
c(n) =
(2/T)*int(x*sin(n*w*t)
,t,T0,T0+T);
end
k = 1:16;
xx1 = a0 +
sum(b.*cos(k*w*t)) +
sum(c.*sin(k*w*t));
Page |9

fplot(xx1, [T0 T0+T]); Approximation with 17 terms


title('Approximation
with 17 terms') 1

0.9

%coefficients for 17 0.8

terms 0.7

0.6
subplot(3,1,1)
0.5
stem(0,a0)
title('a0 for 17 0.4

Terms') 0.3

subplot(3,1,2) 0.2
stem(k,b) 0.1
title('b1 for 17
0
Terms')
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
subplot(3,1,3)
stem(k,c)
title('c1 for 17
Terms') a0 for 17 Terms

0.6

0.4

0.2

0
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1

b1 for 17 Terms
0

-0.1

-0.2
0 2 4 6 8 10 12 14 16

c1 for 17 Terms
0.3

0.2

0.1

0
0 2 4 6 8 10 12 14 16

Conclusion:
In this lab we used the knowledge of last labs and the commands used previously to
expand a signal to Trigonometric Fourier series. In this lab we also studied different
properties of Fourier series. This process in crucial in the signal processing field since it
reveals the frequency content of signal and simplifies the calculation of systems’ output.
We have also learned to represent these signals in MATLAB.

You might also like