NDX2GPS - convert indices to gps times gps = ndx2gps(ndx,fs,gps0) ndx index or vector of indices fs sample rate gps0 gps time of first sample. Either a scalar or a struct with elements sec, ns. gps struct (array) gps time relative to time of first sample (:).sec seconds (:).ns nanoseconds
0001 function gps = ndx2gps(ndx,fs,gps0) 0002 % NDX2GPS - convert indices to gps times 0003 % 0004 % gps = ndx2gps(ndx,fs,gps0) 0005 % 0006 % ndx index or vector of indices 0007 % fs sample rate 0008 % gps0 gps time of first sample. Either a scalar or a struct 0009 % with elements sec, ns. 0010 % 0011 % gps struct (array) gps time relative to time of first sample 0012 % (:).sec seconds 0013 % (:).ns nanoseconds 0014 0015 % $Id: ndx2gps.m,v 1.1 2004/05/19 15:04:00 stuver Exp $ 0016 0017 sec = (ndx-1)/fs; 0018 if (isstruct(gps0)) 0019 sec = sec + gps0.sec + gps0.ns/1e9; 0020 else 0021 sec = sec + gps0; 0022 end 0023 0024 ns = (sec - floor(sec))*1e9; 0025 sec = floor(sec); 0026 ns = floor(ns); 0027 gps = struct('sec',num2cell(sec),'ns',num2cell(ns)); 0028 0029 return