%
% plots and prints percentile points of a time series
%
%   [ pc, h ] = pctiles( data[, pcpts] )
%
%   pc    = data values at percentile points
%   h     = handle of plot
%   data  = data time series
%   pcpts = percentile percentage points
%           (default is 0,5,10,15,...,90,95,100)
%
% Bob Newell, November 1996
%
function [ pc, h ] = pctiles( data, pcpts )
%
dat = values( data(:) );
n = length( dat );
if nargin == 1,
  pcpts = [0:20]*5;
end;
pcpts = pcpts(:);
%
h = figure;
plot( [1:n]*100/n, sort(dat) );
ylabel( 'Sorted Data Values' );
xlabel( 'Percentage of Points' );
grid;
%
pc = spline( [1:n]*100/n, sort(dat), pcpts );
[ pcpts pc ]
%
end;
