% file:      	padding.m, (c) Matthew Roughan, Thu Aug  5 2004
%
N = 32;
x = (1:N)/N;
f1 = 3.3333;
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, 'ylim', [-1.2 1.2], 'xlim', [0 max(x)], 'xtick', [], 'ytick', []);
ylabel('signal');
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, 'xlim', [-N/2 N/2], 'ytick', []);
ylabel('power');
xlabel('frequency');
set(gcf, 'PaperUnits', 'centimeters', 'PaperPosition', [0 0 30 15])
print('-depsc', 'Plots/padding.eps');

%%%%%%% pad the data
K = 3;
pad = zeros(1,length(y1)*K);
pad((1:length(y1))) = y1;
x_u = (1:K*N)/(K*N);
figure(2)
subplot(2,1,1);
hold off
plot([x_u; x_u], [zeros(size(pad)); pad],'b', 'linewidth', 3);
hold on
plot(x_u, pad, 'bo', 'linewidth', 4);
ylabel('signal');
set(gca, 'linewidth', 3, 'fontsize', 18, 'ylim', [-1.2 1.2], 'xlim', [0 max(x)], 'xtick', [], 'ytick', []);
z2 = fftshift(abs(fft(pad)).^2);
subplot(2,1,2);
hold off
plot([-K*N/2:K*N/2-1; -K*N/2:K*N/2-1], [zeros(1, K*N); z2], 'b', 'linewidth', 4);
hold on
plot(-K*N/2:K*N/2-1, z2, 'bo', 'linewidth', 3);
set(gca, 'linewidth', 3, 'fontsize', 18, 'xlim', [-K*N/2 K*N/2], 'ytick', []);
ylabel('power');
xlabel('frequency');
set(gcf, 'PaperUnits', 'centimeters', 'PaperPosition', [0 0 30 15])
print('-depsc', 'Plots/padding_1.eps');



