function sprspplot(x,dt,Nb,Nh,c);
% function sprspplot(x,dt,Nb,Nh,c);
% computes the spectrogram and the reassigned spectrogram
% of a signal x. dt is the distance between two analysis
% instants, Nb is the number of frequency bins of the 
% representation and Nh is the window length. Choose
% c=0 for black and white representation, and c=1 for a
% colored one.
%
% input parameters:
%     X   input signal
%     DT  time axis, sampling step
%     NB  frequency axis, freq. bin number
%     NH  (Gaussian) window length
%     C   color selection flag (C=0: bw, C=1, color)
%
% example:
% Nx =  16 ; fmin = 0 ; fmax = 0.5 ; Ny = 256; % signal
% Nh = 255 ;   dt = 1 ;   Nb = 128 ;  c =   0; % TFD and display
%
% x  = gchirp(Nx,fmin,fmax); Lx = length(x);
% y  = zeros(Ny,1); y(Ny/2-Lx/2:Ny/2+Lx/2-1) = x;
% sprspplot(y,dt,Nb,Nh,c);

% P. Flandrin, Feb. 12, 2001
% [Time-frequency reassignment: from principles to algorithms]
% Figure 3

% define the spectrogram window
h = window(Nh,'Gauss');

% define time vector 
% [time instants at which the spectrogram will be computed]
Nx = length(x);
t = 1:dt:Nx;

% compute the spectogram of signal x
% at time intants t
% with 2*Nb frequency points [i.e., 2*Nb samples for the FFT time-base]
% using window h
% the last parameter is a progression indicator flag [1=shown, 0=not shown]

[sp,rsp] = tfrrsp(x,t,2*Nb,h,1);

% set the colormap

if c == 1
 colormap(jet)
else
 colormap(flipud(gray))
end

% plot everything

figure(gcf); % put the figure in the forefront

subplot(1,2,1)
imagesc(sp(1:Nb,:));
axis('xy');
axis('square')
set(gca,'XTick',[],'YTick',[])
xlabel(['window/signal = ',int2str(Nh),'/',int2str(Nx),' points'])
title('spectrogram')

subplot(1,2,2)
imagesc(rsp(1:Nb,:));
axis('xy'); axis('square');
set(gca,'XTick',[],'YTick',[])
title('reassigned spectrogram')
xlabel(['window/signal = ',int2str(Nh),'/',int2str(Nx),' points'])

% note: axis('xy') sets the origin at the bottom-left angle and
% the y-axis orientation from the bottom to the top [usual graph plot] 
