% M13-gibbs.diary % Matlab script to generate an animation of the way that % Gibbs phenomenon ears arise from the convolultion of % an ideal frequency response with a sinc function (the % fourier transform of a rectangular window) in the % frequency domain. % 2010-11-23 Dan Ellis dpwe@ee.columbia.edu % Generate an ideal frequency response H = [0, ones(1,127), 0]; % Generate a sinc function X = sin(-60:.2:60)./(-60:.2:60); X(301)=1; % to resolve the sin(0)/0 point % We could have constructed the rectangular window in the % time domain and taken its FFT, e.g.: x = zeros(1,601); % We put points at the start and the end, so (periodically % extended) window is symmetric about its zero point: x(1:21) = 1; % 21 points at the start x(end-19:end) = 1; % 20 points at end for 41 points total X = fftshift(fft(x)); % fftshift puts low-frequency in the middle % Normalize peak amplitude X = X/max(X); % Run the animation convanim(X,H); % convanim(X,H,1) writes the movie as well as just displaying