Generate Barker code


The BarkerCode object generates Barker codes to perform synchronization. Barker codes are subsets of PN sequences. They are short codes, with a length at most 13, which have low-correlation sidelobes. A correlation sidelobe is the correlation of a codeword with a time-shifted version of itself.

To synchronize using a Barker code:

  1. Define and set up your Barker code object. See Construction.

  2. Call step to synchronize according to the properties of comm.BarkerCode. The behavior of step is specific to each object in the toolbox.


Starting in R2016b, instead of using the step method to perform the operation defined by the System object™, you can call the object with arguments, as if it were a function. For example, y = step(obj) and y = obj() perform equivalent operations.


H = comm.BarkerCode creates a Barker code generator System object, H, that generates a Barker code of a specified length.

H = comm.BarkerCode(Name,Value) creates a Barker code generator object, H, with each specified property set to the specified value. You can specify additional name-value pair arguments in any order as (Name1,Value1,...,NameN,ValueN).



Length of generated code

Specify the length of the Barker code as a numeric, integer scalar in the set {1, 2, 3, 4, 5, 7, 11, 13}. The default is 7. The codes that the object generates for a specified length are listed in the following table:

LengthBarker code
2[-1 1]
3[-1 -1 1]
4[-1 -1 1 -1]
5[-1 -1 -1 1 -1]
7[-1 -1 -1 1 1 -1 1]
11[-1 -1 -1 1 1 1 -1 1 1 -1 1]
13 [-1 -1 -1 -1 -1 1 1 -1 -1 1 -1 1 -1]


Number of output samples per frame

Specify the number of Barker code samples that the step method outputs as a numeric, integer scalar. The default is 1. If you set this property to a value of M, then the step method outputs M samples of a Barker code sequence of length N. N represents the length of the code that you specify in the Length property.


Data type of output

Specify the output data type as one of double | int8. The default is double.


resetReset states of Barker code generator object
stepGenerate Barker code
Common to All System Objects

Allow System object property value changes


expand all

Create a Barker code object having 10 samples per frame.

  barker = comm.BarkerCode('SamplesPerFrame',10)
barker = 
  comm.BarkerCode with properties:

             Length: 7
    SamplesPerFrame: 10
     OutputDataType: 'double'

Generate the Barker code sequence.

  seq = barker()
seq = 10×1



This object implements the algorithm, inputs, and outputs described on the Barker Code Generator block reference page. The object properties correspond to the block parameters, except:

  • The block Sample time parameter does not have a corresponding property.

  • The object only implements frame based outputs.

Extended Capabilities

Introduced in R2012a