%
%    SHOWSPEC(S)
%    SHOWSPEC(S,F,T)
%
% Show spectrogram S in a nice graph. When vectors F and T are given,
% the appropriate frequencies (F) and timepoints (T) are plotted on the
% vertical and horizontal axes, respectively.
% When a spectrogram is constructed from the Matlab spectrogram.m, in
% principle a complex-valued matrix S is obtained. If this is not
% converted into something real-valued, the abs(S) is actually plotted
% in the figure.

function showspec(S,f,t)

if ~isreal(S)
   S = abs(S);
   warning('showspec:NotRealS','Spectrum S is complex, using abs(S).');
end

if nargin<2
   imagesc(S);
   axis xy;
   xlabel('timepoint');
   ylabel('frequency');
else
   imagesc(t,f,S);
   axis xy;
   xlabel('time (s)');
   ylabel('frequency');
end


