HW_2 - 2. For 6.1_1a and 6.1_2, plot the Fourier series...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 2. For 6.1_1a and 6.1_2, plot the Fourier series approximation using the first 5, 10 and 15 harmonics in MATLAB. Fourier series approximation using first 5 harmonics 1.5 1 0.5 0 -0.5 -1 -1.5 -8 -6 -4 -2 0 2 4 6 8 Fourier series approximation using first 10 harmonics 1.5 1 0.5 0 -0.5 -1 -1.5 -8 -6 -4 -2 0 2 4 6 8 Fourier series approximation using first 15 harmonics 1.5 1 0.5 0 -0.5 -1 -1.5 -8 -6 -4 -2 0 2 4 6 8 Matlab code: N_harmonics = 5; %number of harmonics t = -9:.001:9; %set time interval and sampling x = zeros(size(t)); %initialize approximation %perform loop summation for k=1:N_harmonics x = x+(4/pi)*[((-1)^(k-1))/(2*k-1)]*cos((2*k-1)*0.5*pi*t); end figure; plot(t,x); axis([-9 9 -1.5 1.5]); title('Fourier series approximation using first 5 harmonics'); Fourier series approximation using first 5 harmonics 1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0 -3pi -2pi -pi 0 pi 2pi 3pi Fourier series approximation using first 10 harmonics 1 0.8 0.6 0.4 0.2 0 -3pi -2pi -pi 0 pi 2pi 3pi Fourier series approximation using first 15 harmonics 1 0.8 0.6 0.4 0.2 0 -3pi -2pi -pi 0 pi 2pi 3pi Matlab code: N_harmonics = 5; %number of harmonics t = -3*pi:.001:3*pi; %set time interval and sampling y = 0.504*ones(size(t)); %initialize approximation %perform loop summation for n=1:N_harmonics y = y+0.504*2/(1+16*n^2)*(cos(2*n*t)-4*n*sin(2*n*t)); end figure; plot(t,y); set(gca,'XTick',-3*pi:pi:3*pi) set(gca,'XTickLabel',{'-3pi','-2pi','-pi','0', 'pi','2pi','3pi'}) axis([-3*pi 3*pi 0 1.2]); title('Fourier series approximation using first 5 harmonics'); ...
View Full Document

This note was uploaded on 06/08/2009 for the course BME 513 taught by Professor Yen during the Spring '07 term at USC.

Page1 / 4

HW_2 - 2. For 6.1_1a and 6.1_2, plot the Fourier series...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online