Main Content


Simulate GNSS measurements for scenarios

Since R2023a


The gnssMeasurementGenerator System object™ simulates global navigation satellite system (GNSS) receiver measurements. The object calculates pseudoranges based on the sensor time and data that specifies the satellite orbital parameters. The object uses only the Global Positioning System (GPS) constellations for calculations. To set the starting positions of the satellites, set the InitialTime property.

To simulate GNSS measurements:

  1. Create the gnssMeasurementGenerator object and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects?



GNSS = gnssMeasurementGenerator returns a gnssMeasurementGenerator System object GNSS that simulates raw global navigation satellite system receiver measurements.


GNSS = gnssMeasurementGenerator(Name=Value) specifies properties using one or more name-value arguments.


expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

For more information on changing property values, see System Design in MATLAB Using System Objects.

Sample rate of the GNSS receiver, specified as a positive scalar in Hz.

Initial time of the GNSS receiver, specified as a datetime object. The object accounts for leap seconds in the conversion between the UTC and the GNSS time.

Origin of the local navigation reference frame, specified as a three-element row vector in geodetic coordinates of the form [latitude longitude altitude]. Specify latitude in degrees, longitude in degrees, and altitude in meters. Altitude is the height above the reference ellipsoid model WGS84.

Elevation mask angle, specified as a scalar in the range [0, 90], in degrees. The object does not use satellites that are in view, but below the mask angle, in estimating the position of the receiver.

Tunable: Yes

Standard deviation of the pseudorange measurement noise, specified as a nonnegative scalar in meters.

Tunable: Yes

Random number source, specified as one of these options::

  • "Global stream" –– Generate random numbers using the current global random number stream.

  • "mt19937ar with seed" –– Generate random numbers using the mt19937ar algorithm with the seed specified by the Seed property.

Data Types: char | string

Initial seed of the mt19937ar random number generator algorithm, specified as a nonnegative integer.


To enable this property, specify RandomStream property as "mt19937ar with seed".




[pseudorangeMeasurements,satellitePositions,status] = GNSS computes the GNSS receiver measurements.

Output Arguments

expand all

Pseudorange measurements of the GNSS receiver, returned as an N-element vector, in meters. N is the number of satellites in view.

Satellite positions in Earth-centered Earth-fixed coordinate system, returned as an N-by-3 matrix. N is the number of satellites in view. Each row is a Cartesian coordinate in meters.

Status of the satellite measurements, returned as a structure containing the field:

  • LOS — Line of sight for each satellite, returned as a logical N-element vector. N is the number of satellites in view. A status of 1 or true indicates that there is line of sight from the receiver to the satellite, and a status of 0 or false indicates there is no line of sight from the receiver to the satellite.

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named obj, use this syntax:


expand all

cloneCreate duplicate System object
stepRun System object algorithm
isLockedDetermine if System object is in use
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object


collapse all

Create variables for the sample rate and the geodetic reference location. Set the sample rate to 1 Hz, and set the reference location to Natick, Massachusetts.

Fs = 1;
refLocNatick = [42.2825 -71.343 53.0352]; 

Create a driving scenario with the reference location set to Natick, and add a car to the scenario.

scene = drivingScenario(GeoReference=refLocNatick);
car = vehicle(scene);

Create a GNSS measurement generator System object with the previously specified sample rate and reference location.

gnss = gnssMeasurementGenerator(SampleRate=Fs,ReferenceLocation=refLocNatick);

Mount the GNSS measurement generator, as a sensor, on the car in the scene.

mountingPosition = [0 0 1.5];

Initialize and advance the scenario.


Get the raw GNSS measurements.

[pr,satPos,status] = gnss()
pr = 7×1
107 ×


satPos = 7×3
107 ×

    1.4493   -0.9269    2.0235
    0.8277   -2.0071    1.5299
    0.1020   -2.5843    0.6043
    1.8150    0.3066    1.9146
   -1.1042   -2.1016    1.1908
    2.2312   -1.4032   -0.3274
   -1.0970   -1.0731    2.1677

status = struct with fields:
    LOS: [7x1 logical]

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2023a