Lab Report No. 10: Signals& Systems EEE-223
Lab Report No. 10: Signals& Systems EEE-223
Signals& Systems
EEE-223
Name
Tayyab Ahmad
Registration Number
FA18-BEE-154
Class
BEE-4C
Instructor’s Name
Ma’am Nida Zamir
Page |2
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
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)
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
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('b1 41Terms')
subplot(3,1,3) -1
0 5 10 15 20 25 30 35 40
stem(k,c) c1 41Terms
0.4
0.2
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
Code Result
clear all;
close all;
% Expressing variables
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
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
(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
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
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
%coefficients for 7 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
terms
b1 for 7 Terms
title('b1 for 7 0
Terms')
-0.1
subplot(3,1,3)
stem(k,c) -0.2
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
0.9
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.