Main Content

gpsWaveformGenerator

Generate GPS waveform (legacy L1 and L2, modernized L1C, L2C, and L5)

Since R2025a

Description

The gpsWaveformGenerator System object™ creates a Global Positioning System (GPS) waveform generator that supports generation of these GPS waveforms.

  • Legacy L1 and L2 — Applies when you set the SignalType property to "legacy".

  • Modernized L1C — Applies when you set the SignalType property to "l1c".

  • Modernized L2C — Applies when you set the SignalType property to "l2c".

  • L5 — Applies when you set the SignalType property to "l5".

To create a GPS waveform generator:

  1. Create the gpsWaveformGenerator 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?

Creation

Description

gpsWaveObj = gpsWaveformGenerator creates a default GPS waveform generator System object.

example

gpsWaveObj = gpsWaveformGenerator(Name=Value) sets properties using one or more name-value arguments. For example, gpsWaveformGenerator(PRNID=10) specifies a pseudo-random noise (PRN) ID of 10.

Properties

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.

Type of baseband signal to generate, specified as one of these options

  • "legacy" — Use this option to generate a legacy L1 or L2 signal.

  • "l1c" — Use this option to generate a modernized L1 signal.

  • "l2c" — Use this option to generate a modernized L2 signal.

  • "l5" — Use this option to generate a modernized L5 signal.

Satellite PRN index, specified as one of these options.

  • Integer in the range [1, 210] — Use this option to input a PRN index for a single satellite.

  • Vector of integers in the range [1, 210] — Use this option to input PRN indices for multiple satellites.

Note

When you set the SignalType property to "l2c", PRN indices must be in the range [1, 63] or [159, 210].

Data Types: double | uint8

Option to enable phase-quadrature for L2C and L2P, specified as a numeric or logical 1 (true) or 0 (false).

  • true — Use this option to set the precision code (P-code) on the in-phase branch (I-branch), and the civil-moderate (CM) code and the civil-long length (CL) code on the quadrature-branch (Q-branch).

  • false — Use this option to set all codes on the I-branch.

Dependencies

To enable this property, set the SignalType property to "l2c".

P-code indicator, specified as a numeric or logical 1 (true) or 0 (false).

In cases where you do not need the P-code, set this property to false to improve the execution speed. When set to false, the P-code on the I-branch is set to 0.

Dependencies

To enable this property, set the SignalType property to "legacy" or "l2c".

Option to enable data with P-code, specified as a numeric or logical 1 (true) or 0 (false). When set to true, data is transmitted along with the P-code.

Dependencies

To enable this property, you must satisfy these conditions.

  • Set the SignalType property to "legacy" or "l2c".

  • Set the EnablePCode property to true.

Option to enable data with coarse acquisition code (C/A-code), specified as a numeric or logical 1 (true) or 0 (false). When set to true, data is transmitted along with the C/A-code.

Dependencies

To enable this property, set the SignalType property to "legacy".

Initial time within one week in seconds, specified as a real scalar in the range [0, 604800].

This property is not visible when the SignalType property to "legacy" and the EnablePCode property to false.

Data Types: double

Sample rate for the signal, in hertz, specified as a numeric scalar greater than 1e6. This property specifies the sample rate of the signal output by the step object function.

Data Types: double

This property is read-only.

Duration of input bits, represented as one of these values.

  • "0.01" — Applies when the SignalType property is set to "l1c" or "l5".

  • "0.02" — Applies when the SignalType property is set to "legacy" or "l2c".

This property is read-only.

Chip rate of the slowest code in the waveform, represented as one of these values.

  • "1.023e6" — Applies when you set the SignalType property is set to "legacy" or "l1c".

  • "511.5e3" — Applies when you set the SignalType property is set to "l2c".

  • "10.23e6" — Applies when you set the SignalType property is set to "l5".

Usage

Description

waveform = gpsWaveObj(navdata) generates the time-domain GPS waveform.

example

Input Arguments

expand all

Navigation data, specified as one of these options.

  • Binary matrix — The number of columns must be equal to the length of the PRNID property, as each column corresponds to a PRNID. The number of rows represents the number of navigation data bits.

  • Cell array — Must contain either one or two elements.

    • Cell array with one element — The cell must contain a binary matrix with the same characteristics for when you specify navdata as a binary matrix.

      For example, consider these cases:

      • Case A — navdata = randi([0 1],100,numsat] creates a binary matrix of size 100-by-numsat.

      • Case B — navdata = {randi([0 1],100,numsat]} creates a cell array of a single element, which is a binary matrix of size 100-by-numsat.

      When navdata is specified as a cell array with a single element (Case B), then the element must contain a binary matrix with the same characteristics as described in Case A.

    • Cell array with two elements — Use this option when you set the SignalType property to "l2c". The gpsWaveObj treats the first element as legacy navigation (LNAV) message bits and the second element as civil navigation (CNAV) message bits. The sizes of the cell elements must be same.

      For all other SignalType property values, gpsWaveObj ignores the second element.

Note

When you set the SignalType property to "l2c" and specify navdata as a binary matrix or a cell array with one element, then gpsWaveObj assigns the same value to both LNAV and CNAV.

Data Types: double | int8 | logical

Output Arguments

expand all

Generated GPS waveform, returned as a matrix. Each column is the waveform of the corresponding PRNID property value.

The number of rows is equal to the product of BitDuration × SampleRate × numBits, where numBits is the number of input bits and is equal to size(navdata,1).

The sample rate of the waveform matches the value specified in the SampleRate property.

Data Types: double
Complex Number Support: Yes

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:

release(obj)

expand all

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

Examples

collapse all

Generate random bits of navigation data.

navdata = randi([0 1],2,1);      

Create a GPS waveform generation System object™, and set its properties.

gpswaveobj = gpsWaveformGenerator;
gpswaveobj.EnablePCode = true;
gpswaveobj.SampleRate = 4*10.23e6;

Generate a legacy GPS waveform.

waveform = gpswaveobj(navdata);

Visualize the spectrum of the waveform.

txscope = spectrumAnalyzer(SampleRate=gpswaveobj.SampleRate, ...
    SpectrumType="power-density",SpectrumUnits="dBW/Hz");
txscope(waveform)

Set the PRN indices, and generate random bits of navigation data.

prn = [4 70];
numsat = length(prn);
numbits = 100;
msg = randi([0 1],numbits,numsat);

Create a GPS waveform generation System object™, and set its properties.

fs = 25e6;
gpswaveobj = gpsWaveformGenerator(SignalType="l1c", ...
                     PRNID=prn,SampleRate=fs);

Generate a GPS L1C waveform.

waveform = gpswaveobj(msg);

Visualize the spectrum of the waveform.

txscope = spectrumAnalyzer(SampleRate=fs, ...
   SpectrumType="power-density",SpectrumUnits="dBW/Hz");
txscope(waveform)

Generate a GPS L2C waveform with random LNAV and CNAV data for four GPS satellites.

Set the PRN indices and generate random LNAV and CNAV data.

prn = [7 11 20 28];
numsat = length(prn);
numbits = 10;
lnavdata = randi([0 1],numbits,numsat);
cnavdata = randi([0 1],numbits,numsat);

Create a GPS waveform generation System object™, and set its properties.

gpswaveobj = gpsWaveformGenerator;
gpswaveobj.SignalType = "l2c";
gpswaveobj.PRNID = prn;
gpswaveobj.SampleRate = 15e6;
gpswaveobj.EnablePCode = true;

Get the characteristic information about the GPS waveform generator.

info(gpswaveobj)
ans = struct with fields:
         CurrentTime: 0
      SecondsElapsed: 0
    NumBitsProcessed: 0

Generate a GPS L2C waveform.

waveform = gpswaveobj({lnavdata cnavdata});
size(waveform)
ans = 1×2

     3000000           4

Generate a GPS L5 waveform, add impairments, and visualize the resultant waveform.

Generate L5 Waveform

Set the PRN indices, and generate random navigation data.

prn = [185, 189];
numsat = length(prn);
numbits = 40;
msg = randi([0,1],numbits,numsat);

Create a GPS waveform generation System object™, and set its properties.

fs = 25e6;
gpswaveobj = gpsWaveformGenerator(SignalType="l5",PRNID=prn, ...
    InitialTime=42123, SampleRate=fs);

Generate a GPS L5 waveform.

waveform = gpswaveobj(msg);
% Generated waveform has 2 columns, corresponding to the two satellites
size(waveform)         
ans = 1×2

    10000000           2

Introduce Impairments

Initialize objects that model the impairments.

fqyoffsetobj = comm.PhaseFrequencyOffset(FrequencyOffsetSource="Input port", ...
    SampleRate=fs);
delayval = 5.23e-4;
delobj = dsp.Delay(round(delayval*fs));

Add impairments to the waveform to get the resultant waveform.

fwave = fqyoffsetobj(waveform,[3e3 -4.6e3]); % Add frequency offset
dwave = delobj(fwave);                        % Add delay
bbwave = sum(dwave,2);                        % Add all signals to get final signal
size(bbwave)                                  % Resultant baseband waveform is a complex column vector
ans = 1×2

    10000000           1

Visualize Waveform

Visualize the resultant waveform.

txscope = spectrumAnalyzer(SampleRate=fs, ...
    SpectrumType="power-density",SpectrumUnits="dBW/Hz");
txscope(bbwave)

Extended Capabilities

expand all

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

Version History

Introduced in R2025a