www.gusucode.com > 步态识别代码视频序列ppt展示及相关文献matlab源码程序 > lslp/example.m

    %
%
%  Comparison of Least-Squares Linear Prediction Maximum Entroy Spectra
%                    and Spectra produced by FFTs.
%
%                      J. E. Boyd - 15-Jul-97
%

%
%
% first example is taken from Barrodale and Erickson's paper
%
%
load signal0.dat;
signal0 = signal0';

% use forback to get the coefficients for forward and backward prediction
%   - compare the values to B&E's paper
disp( 'Prediction coefficients for Barrodale and Erickson''s example' );
a = forback( signal0, 4 )

% use comp spectrum to compute the spectrum from the coefficents
[f, pwr1] = compspect( a, 1000 );

% compute the spectrum from an FFT
[f, pwr2] = fftspect( signal0, 1000 );

% scale the two power spectra and compare in a plot
pwr1 = pwr1 / max( pwr1 );
pwr2 = pwr2 / max( pwr2 );
disp( 'Plotting example 1 ...' );
plot( f, [pwr1, pwr2] );
title( 'Barrodale and Erickson Example' );
disp( 'note that the peak in the FFT spectrum isn''t even' );
disp( '  at the correct frequency' );


%
%
% second example consists of three samples of a sinusoid
%
%
load signal1.dat;
signal1 = signal1';

%  first the linear prediction method
[f, pwr1] = compspect( forback( signal1, 2 ), 1000 );
%  now the FFT version
[f, pwr2] = fftspect( signal1, 1000 );

% scale and plot them
pwr1 = pwr1 / max( pwr1 );
pwr2 = pwr2 / max( pwr2 );
figure;
disp( 'Plotting example 2 ...' );
plot( f, [pwr1, pwr2] );
title( 'Short (5-sample) Sinusoid Series' );
disp( 'Note the resolution that the linear prediction method yields' );


%
%
%  now try an example from the gait study, y_c for one sequence
%
%

% read the signal and remove the background
load signal2.dat
signal2 = subbackground( signal2' );

%  first the linear prediction method
[f, pwr1] = compspect( forback( signal2, 20 ), 1000 );
%  now the FFT version
[f, pwr2] = fftspect( signal2, 1000 );

% scale and plot them
pwr1 = pwr1 / max( pwr1 );
pwr2 = pwr2 / max( pwr2 );
figure;
disp( 'Ploting example 3 ...' );
plot( f, [pwr1, pwr2] );
title( 'Power Spectra for Example y_c Series' );
disp( 'Note the side-lobes everywhere in the FFT spectrum' );