Professional Documents
Culture Documents
Signals and Systems EEE223: Name Tayyab Ahmad Khan
Signals and Systems EEE223: Name Tayyab Ahmad Khan
Signals and Systems EEE223: Name Tayyab Ahmad Khan
EEE223
Lab 09
Class 4-C
Code Plots
clear all
close all
T0 = 0; Single Period
0.4
T= 6;
w = 2.*pi./T; 0.2
syms t;
0
x = t.*exp(-t); 0 1 2 3 4 5 6
subplot(3,1,1) t
title('Single Period')
0.2
t1 = T0:0.01:T;
0
x1 = t1.*exp(-t1); 0 5 10 15 20 25
x4 = repmat(x1,1,4);
Aproximation with 81 Terms
t3 = linspace(0,4.*T,length(x4)); 0.4
subplot(3,1,2)
0.2
plot(t3,x4)
title('Four periods') 0
0 5 10 15 20
t
for k =-40:40
a(k+41) =
(1/T).*int(x.*exp(1i.*k.*w.*t),
t, T0, T0+T);
ex(k+41) = exp(1i.*k.*w.*t);
end
xx = sum(a.*ex);
subplot(3,1,3)
ezplot(xx,[T0 T0+4.*T])
%#ok<EZPLT>
title('Aproximation with 81
Terms')
Task 02: Plot the coefficients of the complex exponential Fourier series for the periodic
2
t
signal that in one period is defined by x(t ) e , 3 t 3 .
Code Plots
clear all 2
exp (- t )
close all
T0 =-3; 1
T = 6;
w = 2.*pi./T;
syms t 0.8
x = exp(-t.^2);
ezplot(x, [T0 T0+T])
%#ok<EZPLT> 0.6
figure
0.4
syms t k n
x = exp(-t);
ak = (1/T)*int(x.*exp(- 0.2
1i*k*w*t), t, T0, T0+T);
n =-3:3;
an = subs(ak, k, n); 0
subplot(2,1,1)
stem(n,abs(an));
subplot(2,1,2) -3 -2 -1 0 1 2 3
stem(n,angle(an)); t
0
-3 -2 -1 0 1 2 3
-1
-2
-3 -2 -1 0 1 2 3
Code Plots
clear all x[t]
close all
T0 = 0; 1
T = 2;
w = 2*pi/T;
syms t k 0.8
x=heaviside(t)-heaviside(t-1);
ezplot(x, [-1 3]) %#ok<EZPLT> 0.6
title('x[t]')
for k=-20:20
a(k+21)=(1/T)*int(x*exp(- 0.4
1i*k*w*t),t,T0,T0+T);
end 0.2
for k=-20:20
ex(k+21)=exp(1i*w*k*t);
end 0
xx=sum(a.*ex);
ezplot(xx,[-5 5]) %#ok<EZPLT> -1 -0.5 0 0.5 1 1.5 2 2.5 3
title('approximation with 41 t
terms') approximation with 41 terms
for k=-100:100 1.2
a(k+101)=(1/T)*int(x*exp(1i*k*w* 1
t),t,T0,T0+T);
end 0.8
for k=-100:100
ex(k+101)=exp(1i*w*k*t); 0.6
end
x2=sum(a.*ex);
0.4
ezplot(x2,[-5 5]) %#ok<EZPLT>
title('approximation with 201
terms') 0.2
ak=(1/T)*int(x*exp(1i*k*w*t),t,t -5 -4 -3 -2 -1 0 1 2 3 4 5
t
0,t0+T);
k1 = -20:20;
ak=subs(a,k,k1);
subplot(2,1,1);
stem(k1,abs(ak));
title('|a_k|, k=-20:20')
subplot(2,1,2)
stem(k1,angle(ak));
title('\angle a_k, k=-20:20')
%magnitude and phase for 201
terms
ak=(1/T)*int(x*exp(1i*k*w*t),t,t
0,t0+T);
k1 = -100:100;
ak=subs(a,k,k1);
subplot(2,1,1);
stem(k1,abs(ak));
title('|a_k|, k=-100:100')
subplot(2,1,2)
stem(k1,angle(ak));
title('\angle a_k, k=-100:100')
Code Plots
clear all x[t]
close all
T0 = 0; 1
T = 2;
w = 2*pi/T;
syms t k 0.8
x=(heaviside(t)-heaviside(t-
1))+(2-t)*(heaviside(t-1)-
0.6
heaviside(t-2));
title('x[t]')
%%%approx upto 3 0.2
for k=-1:1
0
a(k+9)=(1/T)*int(x*exp(1i*k*w*
t),t,T0,T0+T);
end -4 -3 -2 -1 0 1 2 3 4
t
for k=-1:1
ex(k+9)=exp(1i*w*k*t);
end approximation with 3 terms
xx=sum(a.*ex); 1.2
1.1
ezplot(xx,[-4 4])
title('approximation with 3 1
terms')
0.9
%approx upto 5
0.8
for k=-2:2
0.7
a(k+9)=(1/T)*int(x*exp(1i*k*w*
t),t,T0,T0+T); 0.6
end
0.5
for k=-2:2
ex(k+9)=exp(1i*w*k*t); 0.4
end
xx=sum(a.*ex); 0.3
-4 -3 -2 -1 0 1 2 3 4
t
ezplot(xx,[-4 4])
title('approximation with 5 approximation with 5 terms
terms') 1.1
0.9
0.6
a(k+9)=(1/T)*int(x*exp(1i*k*w* 0.5
t),t,T0,T0+T); 0.4
end
0.3
for k=-3:3
ex(k+9)=exp(1i*w*k*t); 0.2
end -4 -3 -2 -1 0 1 2 3 4
xx=sum(a.*ex); t
ezplot(xx,[-4 4]) approximation with 7 terms
title('approximation with 7
terms') 1.1
0.7
a(k+9)=(1/T)*int(x*exp(1i*k*w* 0.6
t),t,T0,T0+T); 0.5
end
0.4
for k=-8:8
ex(k+9)=exp(1i*w*k*t); 0.3
end 0.2
xx=sum(a.*ex); 0.1
-4 -3 -2 -1 0 1 2 3 4
t
ezplot(xx,[-4 4])
title('approximation with 17 approximation with 17 terms
terms')
1
0.8
0.6
0.4
0.2
-4 -3 -2 -1 0 1 2 3 4
t
Critical Analysis:
In this lab, we have learned a way of analyzing a continuous time signal into frequency components
given by sinusoidal signals. We learned some new commands like ezplot, it plots a symbolic expression,
equation, or function f. By default, ezplot plots a unilabiate expression or function over the range [–2π 2π]
or over a subinterval of this range. This process in crucial in the signal processing field since it reveals the
frequency content of signal and simplifies the calculation of systems’ output. The analysis is based on
the Fourier series. In this lab we also used different methods to express a signal in sum of
different oscillating functions. There was a simple algorithm in this lab which came in handy
while defining the Fourier series coefficients ak.