% zero insertion
s = textread('pulse.txt');
% convert s to single row
s = s';
s = s(:)';

factor = 2;
[s_hat a b] = DFT(s);
% Perform "zero insertion" by zero-extending fourier transform
a(length(a)*factor)=0;
b(length(b)*factor)=0;

% Inverse transform back to time domain
s_hat = DFTinv(a,b,length(s)/2*factor,length(s)*factor);
subplot(311);
title('2x Interpolation');
plot((0:(length(s_hat)-1))/factor,s_hat, 'g.');
hold on;
plot(0:(length(s)-1),s, 'ko');
xlim([40 60]);
xlabel('t (s)');
hold off;
title('s,s\_hat');

factor = 5;
[s_hat a b] = DFT(s);
% Perform "zero insertion" by zero-extending fourier transform
a(length(a)*factor)=0;
b(length(b)*factor)=0;

% Inverse transform back to time domain
s_hat = DFTinv(a,b,length(s)/2*factor,length(s)*factor);
subplot(312);
plot((0:(length(s_hat)-1))/factor,s_hat, 'g.');
hold on;
plot(0:(length(s)-1),s, 'ko');
xlim([40 60]);
hold off;
xlabel('t (s)');
title('5x Interpolation');

factor = 10;
[s_hat a b] = DFT(s);
% Perform "zero insertion" by zero-extending fourier transform
a(length(a)*factor)=0;
b(length(b)*factor)=0;

% Inverse transform back to time domain
s_hat = DFTinv(a,b,length(s)/2*factor,length(s)*factor);
subplot(313);
plot((0:(length(s_hat)-1))/factor,s_hat, 'g.');
hold on;
plot(0:(length(s)-1),s, 'ko');
xlim([40 60]);
hold off;
xlabel('t (s)');
title('10x Interpolation');


