Main Content

gpsL2CCodes

Generate CM and CL codes for GPS L2C

Since R2025a

    Description

    [CM,CL] = gpsL2CCodes(PRNID) generates civil-moderate (CM) and civil-long (CL) codes, as specified in the modernized Global Positioning System (GPS) L2 civil (L2C) standard IS-GPS-200 sections 3.2.1.4 and 3.2.1.5 [1], for the satellite pseudo-random noise (PRN) indices specified in PRNID.

    example

    Examples

    collapse all

    Generate the CM and CL codes for a GPS L2C signal.

    Specify the PRN IDs for the GPS satellites.

    PRNID = [1 11 180]; 

    Generate the CM and CL codes for the set PRN IDs.

    [CM,CL] = gpsL2CCodes(PRNID);

    Check the sizes of generated CM and CL code matrices. Note that each contains the same number of rows as the number of specified PRN IDs.

    size(CM)
    ans = 1×2
    
           10230           3
    
    
    size(CL)
    ans = 1×2
    
          767250           3
    
    

    Input Arguments

    collapse all

    GPS satellite PRN index, specified as one of these options.

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

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

    For details on how to generate these CM and CL codes for a specific PRNID, refer to these tables in GPS L2C standard IS-GPS-200N [1].

    • PRN ID in the range [1, 63] — Table 3-IIa and Table 3-IIb for the code phase assignments of L2C CM and CL codes.

    • PRN ID in the range [159, 210] — Table 6-II for additional code phase assignments of L2C CM and CL codes.

    Data Types: double | uint8

    Output Arguments

    collapse all

    Civil-moderate code, returned as a binary-valued vector or matrix. The number of rows is equal to the code period of 10230, and the number of columns is equal to the number of elements in PRNID.

    CM codes are 20 milliseconds long with a chip rate of 511.5 kilochips per second (kcps). CM is a logical array with dimensions 10230-by-length(PRNID).

    Data Types: logical

    Civil-long code, returned as a binary-valued vector or matrix. The number of rows is equal to the code period of 767250, and the number of columns is equal to the number of elements in PRNID.

    CL codes are 1.5 seconds long with a chip rate of 511.5 kcps. CL is a logical array with dimensions 767250-by-length(PRNID).

    Data Types: logical

    References

    [1] IS-GPS-200N. "NAVSTAR GPS Space Segment/Navigation User Segment Interfaces." GPS Enterprise Space & Missile Systems Center (SMC) - LAAFB, August, 2022.

    Extended Capabilities

    expand all

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

    Version History

    Introduced in R2025a