

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


ME2016, Dr. Ferri Example showing Fourier series applied to a unit-amplitude square wave of period T = 2 and fundamental frequency 0 = 1 rad/s. » t=0:0.001:20; » Y=[]; » for n=1:2:51; y=sin(nt)/n; Y=[Y; y]; end » Y = 4Y/pi; » plot(t,Y(1,:)) 0 2 4 6 8 10 12 14 16 18 20 -1.
-0. 0
1
Now, add the first 3 rows of Y to get the 1st^ plus 3rd^ plus 5th^ harmonic. (Note that when the Matlab “sum” command is applied to a matrix, it gives a row-vector that is the sum of the rows of the matrix. Also recall that Y(1:3,:) gives the first 3 rows of the matrix Y.) » plot(t,sum(Y(1:3,:))) -1.
-0. 0
1
Now, let’s add the first 6 rows, giving the sum of odd harmonic numbers 1 through 11: » plot(t,sum(Y(1:6,:))) 0 2 4 6 8 10 12 14 16 18 20 -1.
-0. 0
1
Now, let’s add some more harmonics: » plot(t,sum(Y(1:12,:))) -1.
-0. 0
1