Main Content

comm.BarkerCode

Generate bipolar Barker code

Description

The comm.BarkerCode System object™ generates a bipolar Barker code. Barker codes have low autocorrelation properties. The short length and low correlation sidelobes make Barker codes useful for frame synchronization in digital communications systems. For more information, see Barker Codes.

To generate a Barker code:

  1. Create the comm.BarkerCode object and set its properties.

  2. Call the object, as if it were a function.

To learn more about how System objects work, see What Are System Objects?.

Creation

Description

barkerCode = comm.BarkerCode creates a bipolar Barker code generator System object to generate a Barker code.

example

barkerCode = comm.BarkerCode(Name,Value) sets properties using one or more name-value pairs. For example, comm.BarkerCode('Length',11,'SamplesPerFrame','11') configures a bipolar Barker code generator System object to output a length 11 Barker code in an 11-sample frame. Enclose each property name in quotes.

Properties

expand all

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.

Length of the generated code, specified as 1, 2, 3, 4, 5, 7, 11, or 13. For more information, see Barker Codes.

Example: 'Length',2 outputs the Barker code [–1;1].

Data Types: double

Samples per output frame, specified as a positive integer. If SamplesPerFrame is M, the object outputs a frame containing M samples comprised of length N Barker code sequences. If necessary, the object repeats the code sequence to reach M samples. N is the length of the generated code, which is set by the Length property.

Data Types: double

Output data type, specified as double or int8.

Data Types: char | string

Usage

For versions earlier than R2016b, use the step function to run the System object algorithm. The arguments to step are the object you created, followed by the arguments shown in this section.

For example, y = step(obj,x) and y = obj(x) perform equivalent operations.

Description

example

y = barkerCode outputs a Barker code frame, as a column vector. If the frame length exceeds the Barker code length, the object fills the frame by repeating the Barker code.

Set the data type of the output with the OutputDataType property.

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)

expand all

cloneCreate duplicate System object
isLockedDetermine if System object is in use
stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object

Examples

collapse all

Create a Barker code System object with 10 samples per frame.

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

             Length: 7
    SamplesPerFrame: 10
     OutputDataType: 'double'

Generate multiple frames by using the default Barker code sequence of length 7. The code wraps within the frame and continues in the next frame.

  for ii = 1:2
      seq = barker()
  end
seq = 10×1

    -1
    -1
    -1
     1
     1
    -1
     1
    -1
    -1
    -1

seq = 10×1

     1
     1
    -1
     1
    -1
    -1
    -1
     1
     1
    -1

Compute the peak sidelobe level for each Barker code.

CodeLength = [1 2 3 4 5 7 11 13]';
psl = zeros(length(CodeLength),1);
barker = comm.BarkerCode;
for ii=1:length(CodeLength)
    spf = CodeLength(ii);
    barker.Length = CodeLength(ii);
    barker.SamplesPerFrame = spf;
    seq = barker();
    sll_dB = 20*log10(abs(xcorr(seq)));
    psl(ii) = -(max(sll_dB));
    release(barker);
end
Sidelobe_dB = psl;
T = table(CodeLength,Sidelobe_dB)
T=8×2 table
    CodeLength    Sidelobe_dB
    __________    ___________

         1                0  
         2          -6.0206  
         3          -9.5424  
         4          -12.041  
         5          -13.979  
         7          -16.902  
        11          -20.828  
        13          -22.279  

More About

expand all

Extended Capabilities

Version History

Introduced in R2012a