function dvaspec(displdata)

%   DVASPEC(DISPLDATA) plots 3 power spectra for the
%      (1) raw displacement data DISPLDATA, 
%      (2) its numerical first derivative (velocity), and
%      (3) its numerical second derivative (acceleration), 
%   in terms of the frequency from 0 to 25 Hz.
%
%  Power spectra are estimated using the modulus squared of the FFT.
%
%   Copyright 2003
%   Centre for Nonlinear Dynamics in Physiology and Medicine

if (~strncmp(displdata,'trem',4)),
  error('Displacement data must be from supplied collection.')
end

eval (['load ' displdata ';']);
x = eval([displdata]);

v = diff(x)*200;
a = diff(diff(x))*(200^2);

tt = (0:5999)/200;
offset=0;

x=x-mean(x);
pxx = abs(fft(x));
fx = 200*(0:(length(x)-1))/length(x);

v=v-mean(v);
pvv = abs(fft(v));
fv = 200*(0:(length(v)-1))/length(v);

a=a-mean(a);
paa = abs(fft(a));
fa = 200*(0:(length(a)-1))/length(a);


subplot(3,1,1)
plot(fx,pxx)
title(['Displacement data: ',displdata,' (Raw)'])
set(gca,'Xlim',[0 25])

subplot(3,1,2)
plot(fv,pvv)
title(['Velocity data: v',displdata,' (Numerical first derivative)'])
set(gca,'Xlim',[0 25])

subplot(3,1,3)
plot(fa,paa)
title(['Acceleration data: a',displdata,' (Numerical second derivative)'])
xlabel('Frequency (Hz)')
set(gca,'Xlim',[0 25])

hold off

return





