% Plot of the bandlimited Fourier series example To = 0.08; % fundamental period N = 500; % samples per period t = To*(0 : 1/N : 3-1/N).'; % three periods shown s = 5.0 + 6.2*cos(25*pi*t+0.3) +... 4.6*cos(100*pi*t-1.9) + 2.8*cos(175*pi*t+2.5); plot(t,s), grid, axis tight % Alternative plot using the DFT C = zeros(500,1); C(1) = 5.0; C(2) = 6.2*exp(j*0.3); C(5) = 4.6*exp(-j*1.9); C(8) = 2.8*exp(j*2.5); c = N*ifft(C); % N and t defined as above c = real(c); plot(t,[c;c;c]), grid, axis tight % Sawtooth waveform approximation To = 0.08; N = 500; t = To*(-1 : 1/N : 1-1/N).'; % two periods shown s = 0*t; for K = 1:100 s = s + (2/pi)*(-1).^(K+1)*sin(2*pi*K*t/To)/K; plot(t,s), title(['K = ' num2str(K)]) pause end % Rectangular pulse approximation To = 0.08; N = 500; t = To*(-1 : 1/N : 1-1/N).'; % two periods shown s = 0*t+1/4; for K = 1:100 s = s + 2*sin(K*pi/4)*cos(2*pi*K*t/To)/(K*pi); plot(t,s), title(['K = ' num2str(K)]) pause end