% file:      	gibbs.m, (c) Matthew Roughan, Sun Aug 22 2004
%
N = 100; x = (1:N)/N;
y = x < 0.5;
z = fft(y);
K = 20;
z(K:end-K) = 0;
yd = real(ifft(z));

figure(1)
subplot(2,1,1);
hold off
plot(x, y, 'b-', 'linewidth', 3);
hold on
plot(x, yd, 'r-', 'linewidth', 3);
title('signal', 'fontsize', 18);
set(gca, 'linewidth', 3, 'fontsize', 18, 'ylim', [-0.2 1.2], 'xlim', [0 max(x)], 'xtick', [], 'ytick', []);

subplot(2,1,2);
hold off
plot(0:N-1, abs(z).^2, 'b-', 'linewidth', 3);
hold on
set(gca, 'linewidth', 3, 'fontsize', 18, 'xlim', [0 N], 'ytick', []);
xlabel('frequency');
title('power spectrum');

set(gcf, 'PaperUnits', 'centimeters', 'PaperPosition', [0 0 24 11])
print('-depsc', 'Plots/gibbs.eps');

