Fourier Series Assignment
Fourier Series Assignment
0.5 −0.5
syms t
x ¼ heaviside(t)"2*heaviside(t"1); 0 −1
ezplot(x,[0 2]);
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
−0.5 t
Commands Results
k ¼ #2:2;
t0 ¼ 0;
T ¼ 2; a ¼ [0, 2*i=pi, 0, #2*i=pi, 0]
w ¼ 2*pi=T;
a ¼ (1=T)*int(x*exp(#j*k*w*t),t,t0,t0þT)
1.5
Approximation with 5 terms
1
0.5
xx ¼ sum(a.*exp(j*k*w*t))
ezplot(xx,[0 10]) 0
title('Approximation with 5 terms')
−0.5
−1
−1.5
0 1 2 3 4 5 6 7 8 9 10
1) Copy and past the codes above and plot in MATLAB. t
2) Calculate Fourier series coefficients for k=-5 to k=5 and use
Approximation the
with 11 code above to plot xx(t)
terms
and check if the calculated coefficients
1 match the coefficients from MATLAB code. For
the calculation part use the properties that we learned in class i.e. example 3.6 and
0.5
table 3.1 on page 206. For example, x(t) is real and odd thus ak should be pure imaginary
k ¼ #5:5;
a ¼ (1=T)*int(x*exp(#j*k*w*t),t,t0,t0þT);
and odd.
xx ¼ sum(a.*exp(j*k*w*t)); 0
0 1 2 3 4 5 6 7 8 9 10
t
k ¼ #10:10; 0.5
a ¼ (1=T)*int(x*exp(#j*k*w*t),t,t0,t0þT);
xx ¼ sum(a.*exp(j*k*w*t)); 0
ezplot(xx,[0 10])
title('Approximation with 21 terms') −0.5
−1
0 1 2 3 4 5 6 7 8 9 10
t
(continued)