# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English version of the page.

# comm.KasamiSequence System object

Generate Kasami sequence

## Description

The `KasamiSequence` object generates a sequence from the set of Kasami sequences. The Kasami sequences are a set of sequences that have good cross-correlation properties.

To generate a Kasami sequence:

1. Define and set up your Kasami sequence object. See Construction.

2. Call `step` to generate a Kasami sequence according to the properties of `comm.KasamiSequence`. The behavior of `step` is specific to each object in the toolbox.

### Note

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.

## Construction

`H = comm.KasamiSequence` creates a KasamiSequence System object, `H`. This object generates a Kasami sequence.

`H = comm.KasamiSequence(Name,Value)` creates a Kasami sequence 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`).

## Properties

 `Polynomial` Generator polynomial Specify the polynomial that determines the shift register's feedback connections. The default is `'z^6 + z + 1'`. You can specify the generator polynomial as a character vector or as a binary numeric vector that lists the coefficients of the polynomial in descending order of powers. The first and last elements must equal `1`. Specify the length of this vector as n+1, where n is the degree of the generator polynomial and must be even. Lastly, you can specify the generator polynomial as a vector containing the exponents of z for the nonzero terms of the polynomial in descending order of powers. The last entry must be `0`. For example, `[1 0 0 0 0 0 1 0 1]` and ```[8 2 0]``` represent the same polynomial, $g\left(z\right)={z}^{8}+{z}^{2}+1$. `InitialConditions` Initial conditions of shift register Specify the initial values of the shift register as a binary numeric scalar or as binary numeric vector. The default is ```[0 0 0 0 0 1]```. Set the vector length equal to the degree of the generator polynomial. When you set this property to a vector value, each element of the vector corresponds to the initial value of the corresponding cell in the shift register. When you set this property to a scalar value, that value specifies the initial conditions of all the cells of the shift register. The scalar, or at least one element of the specified vector, requires a nonzero value for the object to generate a nonzero sequence. `Index` Sequence index Specify the index to select a Kasami sequence of interest from the set of possible sequences. The default is `0`. Kasami sequences have a period equal to N = 2n –1, where n indicates a nonnegative, even integer equal to the degree of the generator polynomial that you specify in the `Polynomial` property. There are two classes of Kasami sequences: those obtained from a small set and those obtained from a large set. You choose a Kasami sequence from the small set by setting this property to a numeric, scalar, integer value in the range [0...2n/2–2]. You choose a sequence from the large set by setting this property to a numeric 1$×$2 integer vector [k m] for k in [–2,..., 2n–2], and m in [–1,..., 2n/2–2]. `Shift` Sequence offset from initial time Specify the offset of the Kasami sequence from its starting point as a numeric, integer scalar value that can be positive or negative. The default is `0`. The Kasami sequence has a period of N = 2n–1, where n is the degree of the generator polynomial that you specify in the `Polynomial` property. The shift value is wrapped with respect to the sequence period. `VariableSizeOutput` Enable variable-size outputs Set this property to true to enable an additional input to the step method. The default is false. When you set this property to true, the enabled input specifies the output size of the Kasami sequence used for the step. The input value must be less than or equal to the value of the `MaximumOutputSize` property. When you set this property to false, the `SamplesPerFrame` property specifies the number of output samples. `MaximumOutputSize` Maximum output size Specify the maximum output size of the Kasami sequence as a positive integer 2-element row vector. The second element of the vector must be 1. The default is [10 1]. This property applies when you set the `VariableSizeOutput` property to true. `SamplesPerFrame` Number of output samples per frame Specify the number of Kasami sequence samples that the step method outputs as a numeric, positive, integer scalar value . The default value is `1`. When you set this property to a value of M, then the `step` method outputs M samples of a Kasami sequence that has a period of N = 2n–1. The value n equals the degree of the generator polynomial that you specify in the `Polynomial` property. `ResetInputPort` Enable generator reset input Set this property to `true` to enable an additional input to the `step` method. The default is `false`. The additional input resets the states of the Kasami sequence generator to the initial conditions that you specify in the `InitialConditions` property. `OutputDataType` Data type of output Specify the output data type as one of `double` | `logical`. The default is `double`.

## Methods

 reset Reset states of Kasami sequence generator object step Generate a Kasami sequence
Common to All System Objects
`clone`

Create System object with same property values

`getNumInputs`

Expected number of inputs to a System object

`getNumOutputs`

Expected number of outputs of a System object

`isLocked`

Check locked states of a System object (logical)

`release`

Allow System object property value changes

## Examples

expand all

Spread BPSK data with a Kasami sequence of length 255 by using the Kasami sequence System object.

Generate binary data and apply BPSK modulation.

```data = randi([0 1],10,1); modData = pskmod(data,2);```

Create a Kasami sequence object of length 255 using generator polynomial .

```kasamiSequence = comm.KasamiSequence('Polynomial',[8 7 4 0], ... 'InitialConditions',[0 0 0 0 0 0 0 1],'SamplesPerFrame',255);```

Generate the Kasami sequence and convert it to bipolar form.

```kasSeq = kasamiSequence(); kasSeq = 2*kasSeq - 1;```

Apply a gain of to ensure that the spreading operation does not increase the overall signal power.

`kasSeq = kasSeq/sqrt(255);`

Spread the BPSK data using the Kasami sequence.

```spreadData = modData*kasSeq'; spreadData = spreadData(:);```

Verify that the spread data sequence is 255 times longer than the input data sequence.

`spreadingFactor = length(spreadData)/length(data)`
```spreadingFactor = 255 ```

Verify that the spreading operation did not increase the signal power.

`spreadSigPwr = sum(abs(spreadData).^2)/length(data)`
```spreadSigPwr = 1.0000 ```

Change the generator polynomial of the Kasami sequence generator to after first releasing the object. Use the character representation of the polynomial.

```release(kasamiSequence) kasamiSequence.Polynomial = 'x^8 + x^3 + 1';```

Generate a new sequence and convert it to bipolar form.

```kasSeq = kasamiSequence(); kasSeq = 2*kasSeq - 1;```

## Algorithms

This object implements the algorithm, inputs, and outputs described on the Kasami Sequence 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.