Compute GPS Week

Version 1.0.0 (1.72 KB) by Daniel Okoh
MATLAB function to obtain the GPS week, and also the number of seconds that have elapsed from the start of the GPS week.
9 Downloads
Updated 16 Dec 2023

View License

This is a MATLAB function to obtain the GPS week, as well as the number of seconds that have elapsed from the start of the GPS week for any given sets of date/time.
The function returns the GPS week numbers (weeks) and the numbers of seconds that has elapsed since the start of the GPS week (secs) for a given set of date vectors (dv)
dv can be a vector or matrix in which the columns correspond to the form [year month day_of_month] or [year month day_of_month hour minute sec] in universal time UT. Example: for 31 March 2023, dv is [2023 3 31] at the UT start of the day, and [2023 3 31 15 36 0] at 15:36:00 UT of the same day.
The syntax is:
[weeks, secs] = gpsweek(dv)
For example, to get the GPS week for 31 March 2023: [weeks, secs] = gpsweek([2023 3 31]) which gives: weeks = 2255 as the GPS week, and secs = 432000 as the number of seconds that has elapsed since the start of the gps week
[week, secs] = gpsweek([2023 3 31 15 36 0]) gives:
week = 2255 as the GPS week, and secs = 488160 as the number of seconds that has elapsed since the start of the gps week
NOTE: THIS FUNCTION CAN BE USED WITH MULTIPLE DATE VECTORS SUPPLIED AT ONCE, AS A MATRIX RETAINING THE SAME NUMBER OF INPUT COLUMNS

Cite As

Daniel Okoh (2024). Compute GPS Week (https://www.mathworks.com/matlabcentral/fileexchange/156487-compute-gps-week), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2023b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0