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

subplot(211);
plot(0:(length(s)-1), s);
title('pulse');
xlabel('t (s)');

subplot(212);
[s_hat a b] = DFT(s, length(s)/2);
mag = length(s)/2*sqrt(a.^2+b.^2);
plot((0:(length(a)-1))/(length(s)), 10*log10(mag.^2));
title( 'Spectrum of a Pulse' );
xlabel('Freq (Hz)');
ylabel('PSD');

pause;


% zero extension
subplot(111);
s(length(s)*10)=0;
[s_hat a b] = DFT(s, length(s)/2);
mag = length(s)/2*sqrt(a.^2+b.^2);
plot((0:(length(a)-1))/(length(s)), 10*log10(mag.^2));
title( 'Interpolated Spectrum of a Pulse' );
xlabel('Freq (Hz)');
ylabel('PSD');