Convert mask vector to shift for linear shift register

## Syntax

``shift = mask2shift(prpoly,mask)``

## Description

````shift = mask2shift(prpoly,mask)` returns the shift that is equivalent to a mask vector for a linear feedback shift register with connections specified by the primitive polynomial `prpoly`. NoteThe input `prpoly` must be primitive to produce a meaningful output. Use the `isprimitive` function to check if `prpoly` is primitive. For more information, see `primpoly` or [2]. ```

example

## Examples

collapse all

Convert masks into shifts for a linear feedback shift register.

Convert a mask of ${x}^{3}+1$ into an equivalent shift for the linear feedback shift register whose connections are specified by the primitive polynomial ${x}^{4}+{x}^{3}+1$.

`s1 = mask2shift([1 1 0 0 1],[1 0 0 1])`
```s1 = 4 ```

Convert a mask of `1` to a shift. The mask is equivalent to a shift of `0`.

`s2 = mask2shift([1 1 0 0 1],[0 0 0 1])`
```s2 = 0 ```

Convert a mask of ${x}^{2}$ into an equivalent shift for the primitive polynomial ${x}^{3}+x+1$.

`s3 = mask2shift('x3+x+1','x2')`
```s3 = 2 ```

## Input Arguments

collapse all

Polynomial input, specified as a binary vector. The length of the mask is equal to the degree of the primitive polynomial and defined in the descending order.

Data Types: `double`

Primitive polynomial, specified as one of the following:

• A character vector or string scalar of a polynomial. For more information, see Representation of Polynomials in Communications Toolbox.

• A binary vector that lists the coefficients of the primitive polynomial in order of descending powers.

• An integer scalar whose binary representation gives the coefficients of the primitive polynomial, where the least significant bit is the constant term.

Data Types: `string` | `char`

collapse all

### Definition of Equivalent Shift

If A is a root of the primitive polynomial and m(A) is the mask polynomial evaluated at A, the equivalent shift s solves the equation As = m(A). To interpret the vector `mask` as a polynomial, treat `mask` as a list of coefficients in order of descending powers.

## References

[1] Lee, J. S., and L. E. Miller, CDMA Systems Engineering Handbook, Boston, Artech House, 1998.

[2] Simon, Marvin K., Jim K. Omura, et al., Spread Spectrum Communications Handbook, New York, McGraw-Hill, 1994.

## Version History

Introduced before R2006a