% file:      	upsampling_1.m, (c) Matthew Roughan, Thu Aug  5 2004
%
N = 32;
x = (1:N)/N;
f1 = 3.4;
y1 = sin(2*pi*f1*x);

figure(1)
subplot(2,1,1);
hold off
plot([x; x], [zeros(size(y1)); y1],'b', 'linewidth', 3);
hold on
plot(x, y1, 'bo', 'linewidth', 4);
set(gca, 'linewidth', 3, 'fontsize', 18);
ylabel('signal');
set(gca, 'ylim', [-1.2 1.2], 'xlim', [0 max(x)], 'xtick', [], 'ytick', []);

z1 = fftshift(abs(fft(y1)).^2);
subplot(2,1,2);
hold off
plot([-N/2:N/2-1; -N/2:N/2-1], [zeros(1, N); z1], 'b', 'linewidth', 4);
hold on
plot(-N/2:N/2-1, z1, 'bo', 'linewidth', 3);
set(gca, 'linewidth', 3, 'fontsize', 18);
set(gca, 'xlim', [-N/2 N/2], 'ytick', []);
ylabel('power');
xlabel('frequency');

set(gcf, 'PaperUnits', 'centimeters', 'PaperPosition', [0 0 30 15])
print('-depsc', 'Plots/upsampling.eps');
