Main Content


Generate Walsh code from orthogonal set of codes


The WalshCode object generates a Walsh code from an orthogonal set of codes.

To generate a Walsh code:

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

  2. Call step to encode the input signal according to the properties of comm.WalshCode. 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.WalshCode creates a Walsh code generator System object, H. This object generates a Walsh code from a set of orthogonal codes.

H = comm.WalshCode(Name,Value) creates a Walsh 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 generated code as a numeric, integer scalar value that is a power of two. The default is 64.


Index of code of interest

Specify the index of the desired code from the available set of codes as a numeric, integer scalar value in the range [0, 1, ... , N-1]. N is the value of the Length property. The default is 60. The number of zero crossings in the generated code equals the value of the specified index.


Number of output samples per frame

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


Data type of output

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


stepGenerate Walsh code from orthogonal set of codes
Common to All System Objects

Allow System object property value changes


Reset internal states of System object


collapse all

Generate 16 samples of a length-64 Walsh code sequence.

walsh = comm.WalshCode('SamplesPerFrame',16)
walsh = 
  comm.WalshCode with properties:

             Length: 64
              Index: 60
    SamplesPerFrame: 16
     OutputDataType: 'double'

seq = walsh()
seq = 16×1



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

  • The object does not have a property to select frame based outputs.

  • The object does not have a property that corresponds to the Sample time parameter.

Extended Capabilities

Introduced in R2012a