Main Content

prbs

Pseudorandom binary sequence

Since R2020a

Description

PRBS = prbs(O,N) calculates a pseudorandom binary sequence P of order O and length N.

example

[PRBS,seed] = prbs(O,N) calculates a pseudorandom binary sequence and the seed needed to continue the sequence.

[PRBS,seed] = prbs(O,N,seed) calculates a pseudorandom binary sequence and the seed needed to continue the sequence using the seed value.

PRBS = prbs(O,N,seed,reverse) uses the reverse linear-feedback shift register (LFSR) tap positions and returns a pseudorandom binary sequence pattern that is essentially the same as running the LFSR backward in time.

time.

example

Examples

collapse all

Create a vector using a pseudorandom binary sequence (PRBS) pattern of the order 4.

O = 4;
N = 2^O-1;
pattern1 = prbs(O,N);

Create another vector, this time using a PRBS pattern of order 4 one bit at a time.

pattern2 = zeros(1,N);
[pattern2(1),seed] = prbs(O,1);
    for ii = 2:N
        [pattern2(ii),seed] = prbs(O,1,seed);
    end

Verify that both patterns are the same.

disp(isequal(pattern1,pattern2))
   1

Input Arguments

collapse all

Order of the pseudorandom binary sequence pattern, specified as a positive integer scalar.

Data Types: double

Length of the pseudorandom binary sequence pattern, specified as a positive integer scalar.

Data Types: double

The reverse linear-feedback shift register (LFSR) tap positions used to calculate a pseudorandom binary sequence pattern. The generated pattern is essentially the same as running the LFSR backward in time.

You can find the LSFR tap positions used by using the command [~,~,tapPosition]=prbs(O,N).

Data Types: double

Output Arguments

collapse all

Pseudorandom binary sequence pattern of order O and length N, returned as a vector.

Data Types: double

Seed value of the pseudorandom binary sequence pattern, returned as a vector. seed is used in subsequent calls to continue the PRBS pattern.

Data Types: double

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2020a