load transients.asc;
x=transients;
w=16; % Modifiable parameter. 
m=1;

sig = x(:);
	n = length(x);
	f = [zeros(n,1); sig; zeros(n,1)];

	if nargin < 2,
		w = n/2;
	end
	if nargin < 3,
		m=1;
	end
	if nargin < 4,
		titl = [];
    end

	nw     = floor(n ./ m);
	specgm = zeros(w+1,nw);
	ix     = ((-w+1):w);

	for l=1:nw,
		t = 1+ (l-1)*m;
		if m==1 & rem(t,16)==1,
			fprintf('spectrogram: t=%i\n',t);
 		end

		tim = n + t + ix;
		seg = f(tim);
		localspec = abs(fft(seg));
		specgm(:,l)  = localspec(1:(w+1));
	end

	spmax = max(max(specgm));
	spmin = min(min(specgm));
   
fg=figure;
r1=subplot(211);
l1=plot(x,'b','markersize',5);axis([1 length(x) min(x) max(x)]);ylabel('Transients'); 
r2=subplot(212); colormap(1-gray(256));image(linspace(0,1,n),linspace(0,1,w+1),256*(specgm-spmin)/(spmax-spmin));axis('xy')
	xlabel('Time')
	ylabel('Frequency')

set(r1,'position',[0.1 0.77 0.85 0.2]);
set(r2,'position',[0.1 0.1 0.85 0.66]);
     
	if nargout==0,
		specgm = [];
    end
