Code covered by the BSD License  

Highlights from
mydate

mydate

by

 

16 Apr 2011 (Updated )

Augments MATLAB's date/time library for improved handling of epochs and formats commonly used in GPS

mydategpsw (epoch)
function varargout = mydategpsw (epoch)
%MYDATEGPSW: Convert epoch to GPS week (and optionally day and second):
% - fractional week; or 
% - integer week number and fractional second of week; or
% - integer week number, integer day of week number, and fractional second of day.
    error(nargoutchk(0, 3, nargout, 'struct'));
    [epoch0, sec_per_week, sec_per_day] = mydategpsw_aux ();
    week = mydatesec(epoch - epoch0) ./ sec_per_week;
    if (nargout < 2),  varargout = {week};  return;  end
    weeknum = floor(week);
    sow = (week - weeknum) .* sec_per_week;
    if (nargout < 3),  varargout = {weeknum, sow};  return;  end
    dow = sow ./ sec_per_day;
    downum = floor(dow);
    sod = sow - downum .* sec_per_day;
    varargout = {weeknum, downum, sod};
end

%!test
%! % mydategpsw()
%! test mydategpswi

Contact us