Home > m > sigproc > time_domain > ltpda_chkts.m

ltpda_chkts

PURPOSE ^

LTPDA_CHKTS checks that the time-series in the input AO(s) are evenly sampled according to the sample rate and an allowed error.

SYNOPSIS ^

function varargout = ltpda_chkts(varargin)

DESCRIPTION ^

 LTPDA_CHKTS checks that the time-series in the input AO(s) are evenly sampled according to the sample rate and an allowed error.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: LTPDA_CHKTS checks that the time-series in the input AO(s) are
              evenly sampled according to the sample rate and an allowed error.

 CALL:        res = ltpda_chkts(a)
              res = 0  - time-stamps samples don't correspond to evenly sampled data
              res = 1  - time-stamps correspond to evenly sampled data

 GUI CALL:    The following call returns a parameter list object that contains
              the default parameter values:

              >> pl = ltpda_xcorr('Params')

 VERSION:     $Id: ltpda_chkts.m,v 1.3 2007/07/16 12:52:21 ingo Exp $

 HISTORY:     02-05-2007 M Hewitson
                 Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varargout = ltpda_chkts(varargin)
0002 % LTPDA_CHKTS checks that the time-series in the input AO(s) are evenly sampled according to the sample rate and an allowed error.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: LTPDA_CHKTS checks that the time-series in the input AO(s) are
0007 %              evenly sampled according to the sample rate and an allowed error.
0008 %
0009 % CALL:        res = ltpda_chkts(a)
0010 %              res = 0  - time-stamps samples don't correspond to evenly sampled data
0011 %              res = 1  - time-stamps correspond to evenly sampled data
0012 %
0013 % GUI CALL:    The following call returns a parameter list object that contains
0014 %              the default parameter values:
0015 %
0016 %              >> pl = ltpda_xcorr('Params')
0017 %
0018 % VERSION:     $Id: ltpda_chkts.m,v 1.3 2007/07/16 12:52:21 ingo Exp $
0019 %
0020 % HISTORY:     02-05-2007 M Hewitson
0021 %                 Creation
0022 %
0023 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0024 
0025 % Check if this is a call for parameters
0026 if nargin == 1
0027   in = char(varargin{1});
0028   if strcmp(in, 'Params')
0029     varargout{1} = getDefaultPL();
0030     return
0031   end
0032 end
0033 
0034 
0035 % Collect together all AOs from the input variables
0036 as = [];
0037 for j=1:nargin
0038   a = varargin{j};
0039   for k=1:length(a)
0040     ak = a(k);
0041     if isa(ak, 'ao')
0042       as = [as ak];
0043     end
0044   end
0045 end
0046 
0047 na = length(as);
0048 
0049 % check each
0050 res = ones(na,1);
0051 for j=1:na
0052   a  = as(j);
0053   d  = a.data;
0054   if isa(d, 'tsdata')
0055     fs    = d.fs;
0056     t     = d.t;
0057     tstep = 1/fs;
0058     % Allowed error is 1% of a sample step
0059     Terr  = 0.01*tstep;
0060 
0061     tt = 0;
0062     % go through time samples
0063     for k=1:length(t)
0064       tdiff = abs(t(k) - tt);
0065       if tdiff > Terr
0066         res(j) = 0;
0067         break
0068       end
0069       tt = tt + tstep;
0070     end
0071   else
0072     error('### I only work with time-series AOs at the moment.');
0073   end
0074 
0075 end
0076 
0077 varargout{1} = res;
0078 
0079 
0080 
0081 %--------------------------------------------------------------------------
0082 % Get default params
0083 function plo = getDefaultPL()
0084 
0085 disp('* creating default plist...');
0086 plo = plist();
0087 disp('* done.');
0088 
0089 % END

Generated on Mon 03-Sep-2007 12:12:34 by m2html © 2003