Main Content


Generate C/A-code for GPS, NavIC, and QZSS satellites

Since R2021b



    code = gnssCACode(prnid,gnsstype) generates coarse acquisition codes (C/A-codes) for the specified pseudo-random noise (PRN) index, prnid, of the satellite constellation specified by gnsstype.


    collapse all

    Specify the unique pseudo-random noise (PRN) index for three GPS satellites.

    prnid = [43 87 10]; % 3 satellites
    gnsstype = "GPS";   % Global navigation satellite constellation type

    Generate the C/A-code for these three GPS satellites.

    code = gnssCACode(prnid,gnsstype);
    ans = 1×2
            1023           3

    Specify the unique PRN index for two NavIC S-band satellites.

    prnid = [2 13];
    gnsstype = "NavIC S-SPS"; % S-band

    Generate the C/A-code for these two NavIC S-band satellites.

    code = gnssCACode(prnid,gnsstype);

    Calculate the output for 10 C/A-code epochs.

    numCAEpochs = 10;
    fullCode = repmat(code,numCAEpochs,1);
    ans = 1×2
           10230           2

    Input Arguments

    collapse all

    Satellite PRN index for which the function generates a C/A-code, specified as a scalar indicating a PRN index for a single satellite or a vector indicating PRN indices for multiple satellites. Valid values of PRN indices depend on the gnsstype input.

    gnsstype ValuePRN Index Valid Value

    integer in the range [1, 210]


    integer in the range [183, 202]

    "NavIC L5-SPS" or "NavIC S-SPS"

    integer in the range [1, 14]

    Data Types: double | uint8

    Type of global navigation satellite constellation, specified as one of these values.

    • "GPS"

    • "QZSS"

    • "NavIC L5-SPS"

    • "NavIC S-SPS"

    Data Types: char | string

    Output Arguments

    collapse all

    Generated C/A-code, returned as one of these options.

    • Column vector of length 1023 — When you specify prnid as a scalar.

    • Matrix — When you specify prnid as a vector. The number of rows of this matrix is equal to 1023, and the number of columns correspond to the length of the prnid vector. Each column of this matrix represents the generated C/A-code corresponding to the element in the prnid vector.

    For detailed information on the relationship between PRN index values and the generated C/A-codes, refer to IS-GPS-200L Table 3-Ia, 3-Ib, and 6-I [1], ISRO-IRNSS-ICD-SPS-1.1 Table 7 [2], and IS-QZSS-PNT-004 Table 3.2.2-2 [3].


    [1] IS-GPS-200L. "NAVSTAR GPS Space Segment/Navigation User Segment Interfaces". GPS Enterprise Space & Missile Systems Center (SMC) - LAAFB, May 14, 2020.

    [2] ISRO-IRNSS-ICD-SPS-1.1. "Signal in space ICD for standard positioning service". ISRO satellite navigation programme. August 2017.

    [3] IS-QZSS-PNT-004. "Quasi-Zenith Satellite System. Interface Specification. Satellite Positioning, Navigation and Timing Service". Cabinet office, Government of Japan. January 25, 2021.

    Extended Capabilities

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

    Version History

    Introduced in R2021b