function drift=spectraldrift(u,widthwindow,skipk)

% drift=spectraldrift(u,widthwindow,skipk,ARorder) : determines spectral drifts
% by analyzing windows of WIDTHWINDOW skipping SKIPK samples until the next window
% and compute the drift in geodesic distance between spectra.
% The spectra are computed with SPECTRUM_GENERIC.m which needs to be
% modified accordingly.

drift=[];
f=spectrum_generic(u(1:widthwindow));
    flast=f;
for k=1+skipk:skipk:length(u)-widthwindow-1,
    f=spectrum_generic(u(k:k+widthwindow-1));
    drift=[drift spectral_distance(f,flast)];
    flast=f;
end

