%%% Multiple Fourier Series %%% Tentative Sample File! %%% UNDER CONSTRUCTION!!!! clc clf clear all % Fourier series for a square wave x=linspace(0,6*pi); n=1:2:999; A=n'*x; f=sin(A); coeffs = (4/pi)./n; y=coeffs*f; y1=coeffs(1:5)*f(1:5,:); y2=coeffs(1:20)*f(1:20,:); figure(1) % plot(x,y,[0 x(end)],[0 0],'k') subplot(3,1,3) plot(x,y,[0 x(end)],[0 0],'k') subplot(3,1,1) plot(x,y1,[0 x(end)],[0 0],'k') subplot(3,1,2) plot(x,y2,[0 x(end)],[0 0],'k') % Fourier Series for a sawtooth n1=1:1000; coeffs1 = -2./n1.*(-1).^n1; A1 = n1'*x; f1=sin(A1); z=coeffs1*f1; z1=coeffs1(1:5)*f1(1:5,:); z2=coeffs1(1:20)*f1(1:20,:); figure(2) % plot(x,z,[0 x(end)],[0 0],'k') subplot(3,1,1) plot(x,z1,[0 x(end)],[0 0],'k') subplot(3,1,2) plot(x,z2,[0 x(end)],[0 0],'k') subplot(3,1,3) plot(x,z,[0 x(end)],[0 0],'k')