Main Content

comm.KasamiSequence

Generate Kasami sequence

Description

The comm.KasamiSequence System object™ generates a sequence from the set of Kasami sequences. The Kasami sequences are a set of sequences that have cross-correlation properties. For more information, see Kasami Sequences.

To generate a Kasami sequence:

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

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

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

Creation

Description

kasamiseq = comm.KasamiSequence creates a KasamiSequence System object. This object generates a Kasami sequence.

example

kasamiseq = comm.KasamiSequence(Name,Value) sets Properties using one or more name-value arguments. For example, 'Polynomial','z^8 + z^4 + z^3 + z^2 + 1' specifies the generator polynomial.

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.

Generator polynomial, specified as one of these options:

  • Character vector or string scalar of a polynomial whose constant term is 1. For more information, see Representation of Polynomials in Communications Toolbox.

  • Binary-valued row vector that represents the coefficients of a polynomial in order of descending powers. The length of this vector must be N + 1, where N is the degree of the polynomial. The first and last entries must be 1, indicating a leading term with degree N and a constant term of 1.

  • Integer-valued row vector of elements that represents the exponents for the nonzero terms of a polynomial in order of descending powers. The last entry must be 0, indicating a constant term of 1.

You can specify the primitive generator polynomial as a row vector of elements that represents the exponents for the nonzero terms of the polynomial in order of descending powers. Alternatively, you can also use the primpoly function to find the primitive polynomials for a Galois field or use the gfprimck function to check if a polynomial is a valid primitive polynomial.

Example: 'z^8 + z^4 + z^3 + z^2 + 1', [1 0 0 0 1 1 1 0 1], and [8 4 3 2 0] represent the same polynomial: z8 + z4 + z3 + z2 + 1.

Data Types: double | char | string

Initial conditions of the shift register, specified as one of these options:

  • Binary-valued scalar — This value specifies the initial conditions of all cells in the shift register.

  • Binary-valued row vector of length equal to the degree of the generator polynomial — Each element of the vector corresponds to the initial value of the corresponding cell in the shift register.

Note

The scalar, or at least one element of the specified vector, requires a nonzero value for the object to generate a nonzero sequence.

Data Types: double

Sequence index, specified as an integer or vector of the form [k m] to select a Kasami sequence of interest from the set of possible sequences. Kasami sequences have a period equal to N = 2n –1, where n is a nonnegative even integer equal to the degree of the generator polynomial that you specify in the Polynomial property.

Two classes of Kasami sequences exist: those obtained from a small set and those obtained from a large set. You can choose a Kasami sequence from the small set by setting this property to an integer in the range [0, 2n/2–2]. You can choose a sequence from the large set by setting this property to a vector of the form [k m]. k must be an integer in the range [–2, 2n–2], and m must be an integer in the range [–1, 2n/2–2]. For more information, see Kasami Sequences.

Data Types: double

Sequence offset from the starting point, specified as an integer. 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.

Data Types: double

Option to enable variable-size outputs, specified as one of these numeric or logical values:

  • false (0) -- Use the SamplesPerFrame property to specify the number of output samples per frame.

  • true (1) -- Use the outputsize input argument to specify the output size of the Kasami sequence. The input value must be less than or equal to the value of the MaximumOutputSize property.

Data Types: logical | double

Maximum output size of the Kasami sequence, specified as a vector of the form [m 1], where m is a positive integer. The first element of the vector indicates the maximum size of the sequence, and the second element of the vector must be 1.

Example: [10 1] specifies a maximum output size of 10-by-1.

Dependencies

To enable this property, set the VariableSizeOutput property to 1 (true).

Data Types: double

Number of output samples per frame, specified as a positive integer.

If you set this property to a value of M, then the output, which contains M samples of a Kasami sequence, has a period of N = 2n–1. The value n is the degree of the generator polynomial that you specify in the Polynomial property.

Dependencies

To enable this property, set the VariableSizeOutput property to false (0).

Data Types: double

Option to enable generator reset input, specified as a logical or numeric false (0) or true(1). Set this property to true (1) to enable the resetseq input argument. The input argument resets the states of the Kasami sequence generator to the initial conditions that you specify in the InitialConditions property.

Data Types: logical | double

Data type of the output Kasami sequence, specified as 'double' or 'logical'.

Data Types: char | string

Usage

Description

outsequence = kasamiseq() generates a Kasami sequence.

outsequence = kasamiseq(outputsize) specifies the length of the output sequence.

To enable this syntax, set the VariableSizeOutput property to 1 (true).

example

outsequence = kasamiseq(resetseq) specifies a reset signal for the sequence generator.

To enable this syntax, set the ResetInputPort property to 1 (true).

outsequence = kasamiseq(outputsize,resetseq) specifies the length of the output sequence and the reset signal for the sequence generator.

To enable this syntax, set the VariableSizeOutput property to 1 (true) and the ResetInputPort property to 1 (true).

Input Arguments

expand all

Length of the output sequence, specified as a nonnegative integer or a vector of the form [n 1], where n is a positive integer. The first element of the vector indicates the length of the output frame, and the second element of the vector must be 1.

The scalar or the first element of the row vector must be less than or equal to the first element of the MaximumOutputSize property value.

Dependencies

To enable this input argument, set the VariableSizeOutput property to 1 (true).

Data Types: double

Reset signal for the sequence generator, specified as a scalar or a column vector with length equal to the number of samples per frame specified by the SamplesPerFrame property.

  • When you specify this input as a nonzero scalar, the sequence generator resets to the specified initial conditions and then generates a new output frame.

  • When you specify this input as a numeric column vector, the sequence generator resets to the specified initial conditions at each sample in the output frame that aligns with a nonzero value in this vector.

Dependencies

To enable this input argument, set the ResetInputPort property to 1 (true).

Data Types: double

Output Arguments

expand all

Kasami sequence, returned as a column vector.

Data Types: double

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

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

Generate binary data, and then apply BPSK modulation to that data.

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

Create a Kasami sequence generator System object, specifying a generator polynomial x8+x4+x3+x2+1, initial conditions of the shift register, and a Kasami sequence of length 255.

kasamiseq = comm.KasamiSequence('Polynomial',[8 4 3 2 0], ...
    'InitialConditions',[0 0 0 0 0 0 0 1],'SamplesPerFrame',255);

Generate the Kasami sequence, and then convert it to bipolar form.

kasSeq = kasamiseq();
kasSeq = 2*kasSeq - 1;

Apply a gain of 1/255 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.

modSigPwr = sum(abs(modData).^2)/length(data)
modSigPwr = 1
spreadSigPwr = sum(abs(spreadData).^2)/length(data)
spreadSigPwr = 1.0000

More About

expand all

References

[1] Proakis, John G. Digital Communications. 4th ed. New York: McGraw Hill, 2001.

[2] Sarwate, D.V., and M.B. Pursley. “Crosscorrelation Properties of Pseudorandom and Related Sequences.” Proceedings of the IEEE 68, no. 5 (1980): 593–619. https://doi.org/10.1109/PROC.1980.11697.

[3] Peterson, W. Wesley, and E. J. Weldon. Error-correcting Codes.1972.

Extended Capabilities

Introduced in R2012a