comm.WalshCode

Generate bipolar Walsh code

Description

The `comm.WalshCode` System object™ generates a bipolar Walsh code from an orthogonal set of codes.

To generate a Walsh code:

1. Create the `comm.WalshCode` object and set its properties.

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

Creation

Syntax

``walshCode = comm.WalshCode``
``walshCode = comm.WalshCode(Name=Value)``

Description

example

````walshCode = comm.WalshCode` creates a Walsh code generator System object. This object generates a Walsh code from a set of orthogonal codes.```
````walshCode = comm.WalshCode(Name=Value)` sets properties using one or more name-value arguments. For example, `Length=11` specifies a Walsh code of length 11.```

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.

Length of generated code, specified as a power-of-two integer.

Data Types: `double`

Index of desired code, from the available set of codes, specified as an integer in the range [0, N-1]. N is the value of the Length property.

The number of zero crossings in the generated code equals the value of the specified index.

Data Types: `double`

Samples per output frame, specified as a positive integer. If you set this property to M, the object outputs a frame containing M samples using the Walsh code specified by the Index property. The object repeats the Walsh code sequence, as needed, to reach M samples. For more information, see Algorithms section.

Data Types: `double`

Output data type, specified as `double` or `int8`.

Usage

Syntax

``y = walshCode``

Description

````y = walshCode` outputs a bipolar Walsh code frame as a column vector. If the frame length exceeds the Walsh code length, the object fills the frame by repeating the Walsh code. For more information, see the Algorithms section.```

Output Arguments

expand all

Walsh code, returned as a column vector.

The code is in a bipolar format with `0` and `1` mapped to `1` and `-1`. 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

 `step` Run System object algorithm `release` Release resources and allow changes to System object property values and input characteristics `reset` Reset internal states of System object

Examples

collapse all

Generate a Walsh code of length 128. Specify the sequence with 16 samples per frame.

```walsh = comm.WalshCode; walsh.Length = 128; walsh.SamplesPerFrame = 16; disp(walsh)```
``` comm.WalshCode with properties: Length: 128 Index: 60 SamplesPerFrame: 16 OutputDataType: 'double' ```

Display the bipolar Walsh code.

`seq = walsh()`
```seq = 16×1 1 1 -1 -1 1 1 -1 -1 1 1 ⋮ ```

Generate a Walsh code of length 256. Set the index of the desired code to 64 and the code sequence to 4 samples per frame.

```walsh = comm.WalshCode; walsh.Length = 256; walsh.Index = 64; walsh.SamplesPerFrame = 4; disp(walsh)```
``` comm.WalshCode with properties: Length: 256 Index: 64 SamplesPerFrame: 4 OutputDataType: 'double' ```

Display the bipolar Walsh code.

`seq = walsh()`
```seq = 4×1 1 1 -1 -1 ```

Algorithms

Walsh codes are defined as a set of N codes, denoted Wj, for j = 0, 1, ... , N - 1, which have the following properties:

• Wj takes on the values +1 and -1.

• Wj[0] = 1 for all j.

• Wj has exactly j zero crossings, for j = 0, 1, ... , N - 1.

• ${W}_{j}{W}_{k}^{T}=\left\{\begin{array}{cc}0& j\ne k\\ N& j=k\end{array}$

• Each code Wj is either even or odd with respect to its midpoint.

Walsh codes are defined using a Hadamard matrix of order N, where N is a nonnegative power of 2 that you specify in the Length property. The `comm.WalshCode` System object outputs a row of the Hadamard matrix. Use the Index property to choose the row of the Hadamard matrix. If you set the Index property equal to an integer j, the output code has exactly j zero crossings, for j = 0, 1, ... , N - 1.

Note, however, that the indexing in Walsh code is different from the indexing in Hadamard code.

Version History

Introduced in R2012a