


LTPDA_CHKTS checks that the time-series in the input AO(s) are evenly
sampled according to the sample rate and an allowed error.
Usage: 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
The following call returns a parameter list object that contains the
default parameter values:
>> pl = ltpda_chkts('Params')
M Hewitson 02-05-07
$Id: ltpda_chkts.m,v 1.2 2007/06/12 12:32:14 hewitson Exp $


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