MATLAB.7 Plotting Fourier Series We plot the partial sums for the Fourier series for abs(x) on [-3,3]. First we compute the coefficients by hand. a(0)=3 , a(m)=-6*(1-(-1)^m)/(m*pi)^2 for m>= 1 , b(m)=0 . Next we make an M-file for the nth partial sum. *********************************************************************** function w=summ(x,n) w=3/2; for m=1:n w=w-cos(m*pi*x/3)*6*(1-(-1)^m)/(m*pi)^2; end *********************************************************************** We want to compare summ(x,n) with the 6-periodic extension of abs(x) ( See the example in Lab Assignment.3 ) . Its M-file is ************************************************************* function w=f(x) z=6*floor((x+3)/6); y=x-z; w=abs(y); ************************************************************* Now we go to the command window and plot summ(x,12) and f(x) on [-6,7] . We use "hold on" and "hold off" to plot the graphs together. ************************************************************************ hold on fplot('summ(x,12)',[-6,7]) fplot('f(x)',[-6,7]) hold off; ************************************************************************ To see how far apart the graphs are find the maximum of abs(f(x)-summ(x,12)) . ( See Lab Assignment.2 ). ASSIGNMENT 7 : Let f(x)=x^2 for -2<=x<2 . Find the Fourier series for f on [-2,2]. Plot the partial series for f,summ(x,8) together with a plot of the 4-periodic extension of f(x) on [-5,6]. For what n is the maximum of abs(f(x)-summ(x,n)) on [-5,6] less than 0.1?