Main Content


Pseudorandom binary maximum length sequence

Since R2024a



    S = apaseq(N) generates a length-N pseudorandom binary almost-perfect autocorrelation sequence (APAS) S. An APAS sequences has a periodic autocorrelation function (PACF) that is zero for all nonzero lags except at N/2.


    collapse all

    Create a phase modulated continuous wave (PMCW) waveform based on an almost perfect autocorrelation sequence (APAS) of length N = 64. Assume the chip width is tau = 1e-6 s. Plot the periodic ambiguity function to verify that it has zero sidelobe level everywhere except at tau*N/2.

    Create an APAS of length N.

    N = 64;
    s = apaseq(N);

    Set the chip width and modulation period.

    tau = 1e-6;
    T = tau*N;
    fs = 10/tau;

    Create a custom phase coded waveform System object™ and generate waveform samples. Set PRF to be equal to the inverse of the modulation period.

    waveform = phased.PhaseCodedWaveform(SampleRate=fs,Code="Custom", ...
    x = waveform();

    Plot the periodic ambiguity function to verify that it has zero sidelobes everywhere except at tau*N/2.


    Input Arguments

    collapse all

    Code sequence length, specified as integer such that N=2*(p+1), where p is a prime number.

    Example: 28

    Data Types: double

    Output Arguments

    collapse all

    Code sequence, returned as a length-N complex-valued column vector. The returned sequence is antipodal, that is it consists of only 1 and -1. The height of the PACF sidelobe at N/2 is N-4.

    Data Types: double
    Complex Number Support: Yes


    The apaseq function uses an algorithm described in [1] to generate an APAS sequence from a p-ary m-sequence D of length M=p2-1. At first, all elements of the APAS S are initialized to -1. Then, the indices of the elements in S that must be set to 1 are obtained as mod(I-1,N)+1, where % I contains indices of the elements in D that are equal to 1.


    [1] Pott, Alexander, and Steven P. Bradley. "Existence and nonexistence of almost-perfect autocorrelation sequences." IEEE transactions on information theory 41, no. 1 (1995): 301-304.

    [2] Haderer, Heinz, Reinhard Feger, and Andreas Stelzer. "A comparison of phase-coded CW radar modulation schemes for integrated radar sensors." In 2014 44th European Microwave Conference, pp. 1896-1899. IEEE, 2014.

    [3] Levanon, N. and E. Mozeson. Radar Signals. Hoboken, NJ: John Wiley & Sons, 2004.

    Extended Capabilities

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

    Version History

    Introduced in R2024a