% Fourier Series 3D Representation clear all, close all, clc % set up a time vector t0=0; tf=.97; dt=(tf-t0)/500; t=[t0:dt:tf]; % Initialize the Fourier Series Expansion wave=zeros(size(t)); Z=[]; % Compute each harmonic and add them up for n=1:2:41, harmonic=4 / (pi * n) * sin(4 * pi * n * t); wave=wave+harmonic; plot(wave) % Store each harmonic as a row in a matrix Z=[Z;wave]; end % Plot the 3-D picture n=[1:2:41]; surf(t,n,Z) xlabel('time') ylabel('n') zlabel('magnitude') shading interp axis([0 1 0 40 -2 2]) view(37.5,57)