Main Content

gnssconstellation

Satellite locations at specified time

Description

example

[satPos,satVel] = gnssconstellation(t) returns the satellite positions and velocities at the datetime t. The function returns positions and velocities in the Earth-centered Earth-fixed (ECEF) coordinate system in meters and meters per second, respectively. If the time zone for the datetime is not specified, it is assumed to be UTC.

example

[satPos,satVel,satID] = gnssconstellation(t,navData) returns the satellite positions, velocities, and IDs at time t in the specified RINEX navigation message data navData.

example

[satPos,satVel,satID] = gnssconstellation(t,navData,GNSSFileType=gnssFileType) additionally specifies the GNSS file type from which you obtained the navigation message data. This syntax enables you to process navigation data obtained from either a RINEX file or a SEM almanac file.

Examples

collapse all

Get the current satellite positions and velocities from the GNSS satellites. Access the orbital parameters from IS-GPS-200M Interface Specification and calculate the position and velocities in ECEF coordinates for the given time. Display the satellite positions.

t = datetime('now','TimeZone','Local');
[satPos,satVel] = gnssconstellation(t);
disp(satPos)
   1.0e+07 *

    1.7997    1.7445   -0.8787
    1.0526   -1.1371    2.1571
   -2.0010    0.2460   -1.7291
   -2.4178   -0.7177   -0.8326
    0.7716   -2.2872    1.1078
    0.0498   -2.6544    0.0778
    1.4417    0.8634    2.0567
   -1.3861    1.0967   -1.9824
    0.9814    2.0349    1.3964
    2.1142    0.0740    1.6059
    0.7922   -1.8565   -1.7263
   -0.5461   -1.4366   -2.1661
   -2.2585    1.3938    0.1044
    0.0350    1.6809    2.0561
   -1.3339   -1.8577   -1.3505
   -2.0578   -1.5985   -0.5142
    2.3808    0.5129   -1.0597
   -1.2596    0.9876    2.1195
   -1.1221   -1.8005    1.5979
    1.2935   -1.3983   -1.8509
   -0.0420    2.6548    0.0668
    1.5233   -0.0315   -2.1755
    2.2153   -1.4506    0.2055
   -0.3268    1.7701   -1.9530
    0.7757    1.3112   -2.1756
   -2.2370    0.1440    1.4245
   -1.4692   -0.8136    2.0576

Use the lookangles function to get the azimuth and elevation angles of satellites for given satellite and receiver positions. Specify a mask angle of 5 degrees. Get the satellite positions using the gnssconstellation function.

Specify a receiver position in geodetic coordinates (latitude, longitude, altitude).

recPos = [42 -71 50];

Get the satellite positions for the current time.

t = datetime('now');
gpsSatPos = gnssconstellation(t);

Specify a mask angle of 5 degrees.

maskAngle = 5;

Get the azimuth and elevation look angles for the satellite positions. The vis output indicates which satellites are visible. Get the total using nnz.

[az,el,vis] = lookangles(recPos,gpsSatPos,maskAngle);
fprintf('%d satellites visible at %s.\n',nnz(vis),t);
10 satellites visible at 31-Aug-2022 05:37:21.

Read one set of GPS satellites from the GPS navigation message in a RINEX file.

filename = "GODS00USA_R_20211750000_01D_GN.rnx"; 
data = rinexread(filename);
gpsData = data.GPS;
[~,satIdx] = unique(gpsData.SatelliteID);
gpsData = gpsData(satIdx,:);

Get the satellite positions, velocities, and IDs at the first time step.

t = gpsData.Time(1);
[satPos,satVel,satID] = gnssconstellation(t,gpsData)
satPos = 31×3
107 ×

   -1.5630   -0.1882    2.1186
    1.3808    2.1970   -0.4861
   -2.0061    0.7606    1.5492
   -2.5625   -0.0140   -0.7096
    1.4896    0.5448   -2.1487
    0.6129    2.5407    0.4615
   -1.0081    1.3751   -1.9877
   -2.5811   -0.6135   -0.3246
   -1.9289    0.8690   -1.6134
    0.9542   -2.2526    1.0113
      ⋮

satVel = 31×3
103 ×

   -0.8888   -2.5914   -0.8416
    0.0362    0.7543    3.1043
    1.1203   -1.6505    2.2591
   -0.8301   -0.4385    2.9967
   -1.6023    2.1607   -0.5493
   -0.3948   -0.4708    3.1591
   -1.0322   -2.4133   -1.1748
    0.4370   -0.1710   -3.1339
   -1.9860   -0.5032    2.1087
    0.9968   -0.8308   -2.8502
      ⋮

satID = 31×1

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
      ⋮

Read GPS navigation message data from a SEM almanac file.

data = semread("semalmanac_2022-4-10.al3")
data=31×16 timetable
            Time            GPSWeekNumber    GPSTimeOfApplicability    PRNNumber    SVN    AverageURANumber    Eccentricity    InclinationOffset    RateOfRightAscension    SqrtOfSemiMajorAxis    GeographicLongitudeOfOrbitalPlane    ArgumentOfPerigee    MeanAnomaly    ZerothOrderClockCorrection    FirstOrderClockCorrection    SatelliteHealth    SatelliteConfiguration
    ____________________    _____________    ______________________    _________    ___    ________________    ____________    _________________    ____________________    ___________________    _________________________________    _________________    ___________    __________________________    _________________________    _______________    ______________________

    12-Apr-2022 16:50:54        2205               2.3347e+05              1        63            0                0.01171          0.014391            -2.4484e-09               5153.6                        -0.9271                      0.28359          -0.23387              0.00038624                    -7.276e-12                  0                     11          
    12-Apr-2022 16:50:54        2205               2.3347e+05              2        61            0               0.020515         0.0074596            -2.5029e-09               5153.6                       -0.95587                     -0.45355          -0.18869             -0.00065327                             0                  0                      9          
    12-Apr-2022 16:50:54        2205               2.3347e+05              3        69            0              0.0040326         0.0096912            -2.5757e-09               5153.6                       -0.59787                      0.29979          -0.59118             -0.00020409                   -1.4552e-11                  0                     11          
    12-Apr-2022 16:50:54        2205               2.3347e+05              4        74            0              0.0017715         0.0059814            -2.4665e-09               5153.6                       -0.25353                     -0.95004           0.31619             -0.00017643                     3.638e-12                  0                     12          
    12-Apr-2022 16:50:54        2205               2.3347e+05              5        50            0              0.0059118         0.0055599            -2.6193e-09               5153.6                       -0.61097                      0.32122           0.61334             -7.8201e-05                             0                  0                     10          
    12-Apr-2022 16:50:54        2205               2.3347e+05              6        67            0              0.0026565          0.014187             -2.452e-09               5153.7                       -0.92973                     -0.28158           -0.1523              0.00026417                    1.4552e-11                  0                     11          
    12-Apr-2022 16:50:54        2205               2.3347e+05              7        48            0               0.015865         0.0028152            -2.5138e-09               5153.6                        0.07053                     -0.72524          -0.44853              0.00032043                             0                  0                     10          
    12-Apr-2022 16:50:54        2205               2.3347e+05              8        72            0              0.0074387         0.0068531            -2.4738e-09               5153.7                        0.72894                     0.048076             0.467             -6.3896e-05                             0                  0                     11          
    12-Apr-2022 16:50:54        2205               2.3347e+05              9        68            0              0.0021076         0.0037479            -2.5029e-09               5153.5                       -0.27053                      0.59743           0.61325             -0.00034428                     3.638e-12                  0                     11          
    12-Apr-2022 16:50:54        2205               2.3347e+05             10        73            0              0.0075555         0.0096321            -2.5793e-09               5153.6                       -0.59875                     -0.79359          -0.88495              -0.0003767                   -1.0914e-11                  0                     11          
    12-Apr-2022 16:50:54        2205               2.3347e+05             11        78            0             0.00031376         0.0064716            -2.5393e-09               5153.7                        -0.9136                      0.85276           0.49013             -4.1962e-05                     7.276e-12                 63                     12          
    12-Apr-2022 16:50:54        2205               2.3347e+05             12        58            0              0.0087256          0.008585            -2.5575e-09               5153.5                        0.42482                      0.40497          -0.64747             -0.00019932                    -7.276e-12                  0                     10          
    12-Apr-2022 16:50:54        2205               2.3347e+05             13        43            0              0.0058503         0.0083656            -2.4374e-09               5153.6                       -0.22159                      0.29646           0.31699              0.00029278                     7.276e-12                  0                      9          
    12-Apr-2022 16:50:54        2205               2.3347e+05             14        77            0              0.0016966         0.0033073            -2.6121e-09               5153.6                        0.41456                      0.97049          -0.63662             -0.00010204                    -3.638e-12                  0                     12          
    12-Apr-2022 16:50:54        2205               2.3347e+05             15        55            0               0.013989         -0.003952            -2.5866e-09               5153.7                       -0.30476                      0.34521           0.16087             -6.9618e-05                     3.638e-12                  0                     10          
    12-Apr-2022 16:50:54        2205               2.3347e+05             16        56            0               0.012782         0.0085545            -2.5611e-09               5153.6                        0.43073                      0.23073           0.76066             -0.00049114                    -3.638e-12                  0                      9          
      ⋮

Get the satellite positions, velocities, and IDs at the first time step.

t = data.Time(1);
[satPos,satVel,satID] = gnssconstellation(t,data,GNSSFileType="SEM")
satPos = 31×3
107 ×

    1.3899   -2.2151    0.3074
   -1.6755    0.5872   -1.9147
    1.5377   -1.2781   -1.7528
    0.6332   -1.6385   -1.9887
   -2.5716    0.5413    0.4215
   -1.0251   -1.1336   -2.1646
    0.2694   -2.3585    1.1775
    1.3414   -0.7139    2.1761
   -0.3881   -2.2626   -1.3395
    1.5043    1.1879    1.8656
      ⋮

satVel = 31×3
103 ×

    0.0014    0.4854    3.2261
    0.8625   -2.4217   -1.4348
    2.2113    0.0321    1.9394
    1.4081    2.1049   -1.2936
   -0.5761   -0.2150   -3.1036
    1.2999   -2.4327    0.6643
    0.9229   -1.1620   -2.6758
    1.5581    2.2893   -0.1743
    1.1480    1.2668   -2.4877
   -2.3150    0.2417    1.6982
      ⋮

satID = 31×1

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
      ⋮

Input Arguments

collapse all

Current time for the satellite simulation, specified as a scalar datetime array.

The default time zone for a datetime array is UTC. For information on specifying a different time zone, see datetime.

GPS start time is January 6, 1980 at 00:00 (UTC). Specifying any datetime prior to this time will use the GPS start time.

Example: datetime('now','TimeZone','Local');

Data Types: datetime

Navigation data, specified as a timetable. For a RINEX file, you can obtain this timetable from the structure returned by the rinexread function. For a SEM almanac file, you can use the timetable returned by the semread function.

Read Navigation Data from RINEX File

The gnssconstellation function can process the GPS or Galileo data read from a RINEX file. The contents of the structure returned by the rinexread function vary depending on the type of satellite system described by the RINEX file. For more information on the contents of the structure, see the rinexread function More About section.

To read GPS navigation message data from a RINEX file, extract the GPS field from the returned structure. For example:

rinexData = rinexread("GODS00USA_R_20211750000_01D_GN.rnx");
navData = rinexData.GPS;

To read Galileo navigation message data from a RINEX file, extract the Galileo field from the returned structure. For example:

rinexData = rinexread("GODS00USA_R_20211750000_01D_EN.rnx");
navData = rinexData.Galileo;

Read Navigation Data from SEM Almanac File

The gnssconstellation function can process the GPS data read from a SEM almanac file. The timetable returned by the semread function contains the parameters of each satellite in the almanac file associated with the specified date. For more information on the contents of the timetable, see the data argument of the semread function.

Because semread returns a timetable, you can directly specify navData as the semread output argument. For example:

navData = semread("semalmanac_2022-1-18.al3")

GNSS file type, specified as "RINEX" or "SEM". Specify the GNSS file type as "RINEX" when specifying the navigation data as a timetable obtained from the structure returned by the rinexread function. Specify the GNSS file type as "SEM" when specifying the navigation data as a timetable returned by the semread function.

Example: GNSSFileType="RINEX"

Example: GNSSFileType="SEM"

Data Types: char | string

Output Arguments

collapse all

Satellite positions in the Earth-centered Earth-fixed (ECEF) coordinate system in meters, returned as an N-by-3 matrix of scalars. N is the number of satellites in the constellation.

Data Types: single | double

Satellite velocities in the Earth-centered Earth-fixed (ECEF) coordinate system in meters per second, returned as an N-by-3 matrix of scalars. N is the number of satellites in the constellation.

Data Types: single | double

Satellite identification numbers, returned as an N-element column vector. N is the number of satellites in the constellation.

Data Types: single | double

More About

collapse all

Orbital Parameters

The initial satellite positions and velocities are defined by orbital parameters in Table A.2-2 in GPS SPS Performance Standard, and are given in Earth-centered Earth-fixed (ECEF) coordinates.

Position calculations use equations from Table 30-II in the same IS-GPS-200M Interface Specification.

Velocity calculations use equations 8.21–8.27 in Principles of GNSS, Inertial, and Multisensor Integrated Navigation Systems [1].

References

[1] Groves, Paul D. Principles of GNSS, Inertial, and Multisensor Integrated Navigation Systems. Boston: Artech House, 2013.

[2] International GNSS Service (IGS), Daily 30-Second GPS Broadcast Ephemeris Data, NASA Crustal Dynamics Data Information System (CDDIS), Greenbelt, MD, USA, Jun. 24, 2021. Accessed Jun. 25, 2021. https://dx.doi.org/10.5067/GNSS/gnss_daily_n_001.

Extended Capabilities

Version History

Introduced in R2021a