gpsWaveformGenerator
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
SignalTypeproperty to"legacy".Modernized L1C — Applies when you set the
SignalTypeproperty to"l1c".Modernized L2C — Applies when you set the
SignalTypeproperty to"l2c".L5 — Applies when you set the
SignalTypeproperty to"l5".
To understand the algorithms associated with each waveform generated using
gpsWaveformGenerator, see Algorithms.
To create a GPS waveform generator:
Create the
gpsWaveformGeneratorobject and set its properties.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
creates a
default GPS waveform generator System object.gpsWaveObj = gpsWaveformGenerator
sets properties using one or more
name-value arguments. For example, gpsWaveObj = gpsWaveformGenerator(Name=Value)gpsWaveformGenerator(PRNID=10)
specifies a pseudo-random noise (PRN) ID of 10.
Properties
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
SignalTypeproperty to"legacy"or"l2c".Set the
EnablePCodeproperty totrue.
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 theSignalTypeproperty is set to"l1c"or"l5"."0.02"— Applies when theSignalTypeproperty 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 theSignalTypeproperty is set to"legacy"or"l1c"."511.5e3"— Applies when you set theSignalTypeproperty is set to"l2c"."10.23e6"— Applies when you set theSignalTypeproperty is set to"l5".
Usage
Input Arguments
Navigation data, specified as one of these options.
Binary matrix — The number of columns must be equal to the length of the
PRNIDproperty, 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
navdataas 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
navdatais 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
SignalTypeproperty to"l2c". ThegpsWaveObjtreats 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
SignalTypeproperty values,gpsWaveObjignores 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
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)
Examples
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)

Algorithms
The sections detail the algorithm used to generate GPS waveforms using
gpsWaveformGenerator.
This section details the algorithm used to generate legacy waveforms using
gpsWaveformGenerator.
You can generate legacy GPS waveforms by following these steps.
Generate C/A-code using
gnssCACode.XOR the incoming legacy navigation (LNAV) data with the C/A-code. Ensure that the sample rates of LNAV data and C/A-code match.
Map bit 0 to +1 and bit 1 to –1 and then place this waveform on the Q-branch.
Generate P-code using
gpsPCode.XOR the incoming LNAV data with the P-code. Ensure that the sample rates of LNAV data and P-code match.
Map bit 0 to +1/sqrt(2) and bit 1 to –1/sqrt(2) and then place this waveform on the I-branch.
The resultant IQ waveform is the legacy waveform, with the P-code waveform on the I-branch and the C/A-waveform on the Q-branch.

This section details the algorithm used to generate GPS L1C waveform using
gpsWaveformGenerator.
You can generate an L1C waveform by following these steps.
Generate the data at 100 bits per second and each bit is of 10 millisecond duration, as defined in IS-GPS-800.
L1C uses two types of ranging codes: a ranging code for the data (L1CD code) and a ranging code for the pilot (L1CP code). The chip rate of both the L1CD and L1CP codes is 1.023 mega chips per second with 10 milliseconds in length. Therefore, the number of chips before repeating is 10,230.
Because one 10 millisecond data bit exactly matches the ranging code block size, one data bit is spread with one block of ranging code.
Spread the L1CD code with the user data bits to obtain the data component. The rate of the user data bits is 100 bits per second.
Spread the L1CP code with the overlay code (L1CO code) to obtain the pilot component. The rate of the L1CO code is 100 bits per second.
Modulate the data component by using BOC (1,1).
Modulate the pilot component by using the time-multiplexed BOC (TMBOC) modulation technique.
The final IQ waveform formed is the GPS L1C waveform. For more information on TMBOC modulation, see GPS L1C Waveform Generation.

This section details the algorithm used to generate GPS L2C waveform using
gpsWaveformGenerator.
You can generate an L2C waveform by following these steps.
Generate an L2-CM and an L2-CL code.
XOR the civil navigation (CNAV) data with only the L2-CM code.
Multiplex the XORed CNAV and L2-CM data bit-by-bit with L2-CL code.
Because L2-CM and L2-CL each consists of 511.5 kilo chips per seconds, the multiplexed stream of bits consists of 1.023e6 chips per second
For the multiplexed stream generated in point 4, map bit 0 to +1 and bit 1 to –1. Place this waveform on the Q-branch.
Generate P-code using
gpsPCode.XOR the incoming legacy navigation (LNAV) data with the P-code. Ensure that the sample rates of LNAV data and P-code match.
For the XORed LNAV and P-code data, map bit 0 to +1/sqrt(2) and bit 1 to –1/sqrt(2) and then place this waveform on the I-branch.
The resultant IQ waveform is the baseband GPS L2C waveform.

This section details the algorithm used to generate GPS L5 waveform using
gpsWaveformGenerator.
You can generate the L5 waveform by following these steps.
Generate GPS L5 CNAV data, as defined in IS-GPS-705 standard.
Generate the ranging code for in-phase (I5-code) and quadrature-phase (Q5-code) components separately, as described in the standard.
Both I5 and Q5-code are at 10.23MHz chip rate and repeat after every 10230 chips. Hence, each code block is of 1 millisecond duration.
The GPS L5 data is at 100 bits per second. XOR each data bit with 10 Newman Huffman code bits for I-branch. This makes the output after this XOR operation to be at 1 kilo baud, meaning every bit will be of 1 millisecond duration, which is equal to one code block of spreading code.
XOR the 1 millisecond bit from the output of step 3 with I5-code block. Map bit 0 to +1/sqrt(2) and bit 1 to -1/sqrt(2) to get the in-phase branch signal component of the final waveform.
Generate 20 bits of Newman Huffman code for Q-branch which is at 1 kilo baud.
XOR each Q5-code block with the Newman Huffman code. Map bit 0 to +1/sqrt(2) and bit 1 to -1/sqrt(2) to get the quadrature-phase branch signal component of the final waveform.
The final IQ waveform formed is the baseband GPS L5 waveform.

Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Version History
Introduced in R2025a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- 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)