gnssconstellation
Satellite locations at specified time
Syntax
Description
[
returns the satellite positions and velocities at the satPos
,satVel
] = gnssconstellation(t
)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.
Examples
Get Current Satellite Positions and Velocities
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.7001 1.9762 -0.5084 1.8656 0.1152 -1.8870 -1.0071 -1.1430 2.1756 0.1286 -1.8707 1.8810 2.5574 0.6702 0.2547 2.3354 -0.1444 1.2567 0.3306 1.6365 -2.0656 -1.9862 -1.4293 1.0327 -1.0279 1.2224 -2.1221 0.2534 2.6154 -0.3867 1.4945 -0.2952 2.1756 0.9875 -1.6349 1.8456 -1.3647 -1.7970 -1.4009 -2.2163 0.8329 -1.2036 2.0087 -1.7371 0.0394 1.4187 -2.0686 -0.8732 0.1303 1.7486 1.9949 -1.7379 -0.3179 -1.9832 0.7198 -1.3582 -2.1660 2.1780 1.3057 0.7782 -2.3300 0.1528 1.2656 1.1664 1.6585 1.7155 1.4006 1.7062 -1.4769 -1.3625 0.8015 2.1343 -0.8608 1.8286 1.7232 -0.4332 -2.6169 -0.1354 0.3901 -2.3333 -1.2074
Get Satellite Look Angles for Receiver Position
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);
8 satellites visible at 26-Nov-2022 09:38:08.
Retrieve Satellite Positions, Velocities, and IDs from RINEX File
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
⋮
Retrieve Satellite Positions, Velocities, and IDs from SEM Almanac File
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
t
— Current time for satellite simulation
scalar datetime
array
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
navData
— Navigation data
timetable
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")
gnssFileType
— GNSS file type
"RINEX"
| "SEM"
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
satPos
— Satellite positions
N-by-3 matrix of scalars
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
satVel
— Satellite velocities
N-by-3 matrix of scalar
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
satID
— Satellite identification numbers
N-element column vector
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
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
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Only MEX functions are supported for code generation.
Version History
Introduced in R2021a
See Also
Objects
Functions
skyplot
|lookangles
|pseudoranges
|receiverposition
|rinexread
|rinexinfo
|semread
Abrir ejemplo
Tiene una versión modificada de este ejemplo. ¿Desea abrir este ejemplo con sus modificaciones?
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)