subplot(111); hold off;
% A signal to transform
N = 100;
x = [linspace(0,0,28),linspace(1,1,12),linspace(0,0,8),linspace(1,1,8),linspace(0,0,N-56)];
plot(x); hold on;
% Some transforms of it
plot(DFT(x,5)); 
plot(DFT(x,20)); 
plot(DFT(x,50));  
hold off;
pause;

% A square wave
x = [linspace(1,1,50),linspace(0,0,50)];
subplot(211);
plot(x); title('Square wave'); xlabel('time (s)'); 
[xhat a b] = DFT(x, 100);
% plot a and b coefficients below
subplot(212); 
plot(a, 'k:'); 
hold on;
plot(b, 'k-');
hold off;
title('fourier transform'); xlabel('freq (Hz)');
pause;

s = textread('pulse.txt');
% convert s to single row
s = s';
s = s(:)';
for (M = 1:length(s)/2)
[s_hat a b] = DFT(s, M);
subplot(211);
plot(abs(a));
title( strcat('cos coefficients - ',num2str(M)) );
subplot(212);
plot(s_hat, 'g-');
hold on;
plot(s, 'k--');
hold off;
title('s,s\_hat');
pause(.1);
end;
