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 M Hewitson 02-05-07 $Id: ltpda_chkts.html,v 1.1 2007/06/08 14:15:11 hewitson Exp $
0001 function res = 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 % M Hewitson 02-05-07 0012 % 0013 % $Id: ltpda_chkts.html,v 1.1 2007/06/08 14:15:11 hewitson Exp $ 0014 % 0015 0016 0017 % Collect together all AOs from the input variables 0018 as = []; 0019 for j=1:nargin 0020 a = varargin{j}; 0021 for k=1:length(a) 0022 ak = a(k); 0023 if isa(ak, 'ao') 0024 as = [as ak]; 0025 end 0026 end 0027 end 0028 0029 na = length(as); 0030 0031 % check each 0032 res = ones(na,1); 0033 for j=1:na 0034 a = as(j); 0035 d = a.data; 0036 if isa(d, 'tsdata') 0037 fs = d.fs; 0038 t = d.t; 0039 tstep = 1/fs; 0040 % Allowed error is 1% of a sample step 0041 Terr = 0.01*tstep; 0042 0043 tt = 0; 0044 % go through time samples 0045 for k=1:length(t) 0046 tdiff = abs(t(k) - tt); 0047 if tdiff > Terr 0048 res(j) = 0; 0049 break 0050 end 0051 tt = tt + tstep; 0052 end 0053 else 0054 error('### I only work with time-series AOs at the moment.'); 0055 end 0056 0057 end 0058 0059 % END