gpsPCode
Description
The gpsPCode
System object™ generates a precision code (P-code) for a Global Positioning System (GPS)
satellite, as defined in IS-GPS-200L Section 3.3.2.2 [1].
To generate a P-code for a GPS satellite:
Create the
gpsPCode
object 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
P-code generator System object.pgenerator
= gpsPCode
sets Properties using one or more
name-value pairs. For example, pgenerator
= gpsPCode(Name,Value
)'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.
PRNID
— GPS satellite PRN index
1
(default) | integer in the range [1, 210] | vector of integer elements in the range [1, 210]
GPS 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 integer elements in the range [1, 210] — Use this option to input PRN indices for multiple satellites.
For details on PRN ID values, see IS-GPS-200L Tables 3-Ia, 3-Ib, and 6-I [1].
Data Types: double
| uint8
OutputCodeLength
— Output code length
10230
(default) | positive integer
Output code length, specified as a positive integer. This length specifies the number of rows in the output P-code.
The default value of 10230
corresponds to 1 millisecond of
P-code, as the P-code chips are at 10.23 MHz.
Tunable: Yes
Data Types: double
| uint64
InitialStateFormat
— Format of the initial state
"seconds"
(default) | "datetime"
| "chips"
Format of the initial state, specified as "seconds"
,
"datetime"
, or "chips"
.
Data Types: char
| string
InitialTime
— Initial time within one week
0
(default) | integer in the range [0, 604,800] | datetime
object
Initial time within one week, specified as one of these options.
Integer in the range [0, 604,800] — Use this option when you set the
InitialStateFormat
property to"seconds"
. In this case, initial time specifies the seconds that have elapsed from the beginning of the week.datetime
object — Use this option when you set theInitialStateFormat
property to"datetime"
. In this case, initial time specifies the time elapsed from the beginning of the week to the time specified bydatetime
object.
Note
The P-code is one week long.
The default value of 0
assumes that you set the
InitialStateFormat
property to
"seconds"
.
Dependencies
To enable this property, set the InitialStateFormat
property
to "seconds"
or "datetime"
.
Data Types: double
InitialNumChipsElapsed
— Initial number of elapsed P-code chips
0
(default) | integer in the range [0, 604,800x10.23e6]
Initial number of elapsed P-code chips, from the beginning of the week, specified as an integer in the range [0, 604,800x10.23e6].
The maximum input value, 604,800x10.23e6, is the total number of chips elapsed in one week (7×24×60×60×10.23e6).
Note
10.23e6
is the number of chips elapsed in one second.
Dependencies
To enable this property, set the InitialStateFormat
property
to "chips"
.
Data Types: double
| uint64
Usage
Syntax
Description
code
= pgenerator()
Output Arguments
code
— Generated binary-valued P-code
vector | matrix
Generated binary-valued P-code, specified as one of these options.
The number of rows is equal to the value of the OutputCodeLength property. The number of columns is equal to the length
of the PRNID
property. Each element of the vector or matrix is of
data type int8
.
Data Types: int8
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)
Specific to gpsPCode
info | Characteristic information about object |
Examples
Generate P-code When Initial Format Is Seconds
Create a precision code generator (P-code) System object™, and then set its properties.
pgen = gpsPCode; pgen.PRNID = [10 50]; % 2 satellites pgen.OutputCodeLength = 1024; pgen.InitialTime = 1800; % Seconds (default) disp(pgen)
gpsPCode with properties: PRNID: [10 50] OutputCodeLength: 1024 InitialStateFormat: "seconds" InitialTime: 1800
Generate the P-code.
code = pgen();
Generate P-code When Initial Format Is Chips
Create the P-code System object™ and set its properties.
pgen = gpsPCode; pgen.PRNID = 45; pgen.OutputCodeLength = 102400;
Set the initial state format as chips. Generate the P-code for the last 5,000 chips in one week.
pgen.InitialStateFormat = "chips"; % 604,800 is the total seconds in one week % 10.23e6 is the number of P-code chips that elapsed in one second pgen.InitialNumChipsElapsed = 604800*10.23e6 - 5000; code = pgen();
Generate P-code When Initial Format Is datetime
Object
Create a P-code System object™ and specify the PRN index and the output code length.
Set the format of the initial state as a datetime
object. Generate the P-code for the current time.
pgen = gpsPCode; pgen.PRNID = 25; pgen.OutputCodeLength = 20460; pgen.InitialStateFormat = "datetime"; pgen.InitialTime = datetime("now"); code = pgen();
Display the properties of the P-code generator.
disp(pgen)
gpsPCode with properties: PRNID: 25 OutputCodeLength: 20460 InitialStateFormat: "datetime" InitialTime: 05-Sep-2024 17:22:31
Get P-Code State Information
Get information from a gpsPCode
System object™ by using the info
object function. Observe how the precision of initial time impacts the generation of the P-code.
Create a P-code generator System object™, and then specify its properties.
format long
pgen = gpsPCode
pgen = gpsPCode with properties: PRNID: 1 OutputCodeLength: 10230 InitialStateFormat: "seconds" InitialTime: 0
pgen.InitialStateFormat = "chips";
pgen.InitialNumChipsElapsed = 8388600;
Get the characteristic information about the P-code generator.
pgen.info
ans = struct with fields:
TotalNumChipsElapsed: 8388600
TotalSecondsElapsed: 0.820000000000000
Advance the time by a quarter of a P-code chip time (that is, 0.25/10.23e6).
pgen1 = gpsPCode; pgen1.InitialTime = pgen.info.TotalSecondsElapsed + 0.25/10.23e6
pgen1 = gpsPCode with properties: PRNID: 1 OutputCodeLength: 10230 InitialStateFormat: "seconds" InitialTime: 0.820000024437928
pgen1.info
ans = struct with fields:
TotalNumChipsElapsed: 8388600
TotalSecondsElapsed: 0.820000000000000
The info
function output shows no increment in the TotalNumChipsElapsed
in this case, because TotalNumChipsElapsed
is calculated internally using the function round
.
Advance the time by half of a P-code chip time now (that is, 0.5/10.23e6).
pgen2 = gpsPCode; pgen2.InitialTime = pgen.info.TotalSecondsElapsed + 0.5/10.23e6
pgen2 = gpsPCode with properties: PRNID: 1 OutputCodeLength: 10230 InitialStateFormat: "seconds" InitialTime: 0.820000048875855
pgen2.info
ans = struct with fields:
TotalNumChipsElapsed: 8388601
TotalSecondsElapsed: 0.820000097751711
The info
function output now shows the TotalNumChipsElapsed
is incremented by one, due to the internal usage of round()
function.
Compare the output of each System object call.
code = pgen();
code1 = pgen1();
code2 = pgen2();
isequal(code, code1) % code and code1 are equal
ans = logical
1
isequal(code1,code2) % code1 and code2 are unequal
ans = logical
0
References
[1] IS-GPS-200L. "NAVSTAR GPS Space Segment/Navigation User Segment Interfaces." GPS Enterprise Space & Missile Systems Center (SMC) - LAAFB, May 14, 2020.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Version History
Introduced in R2021b
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.
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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)