Communications Toolbox    
randerr

Generate bit error patterns

Syntax

Description

For all syntaxes, randerr treats each row of out independently.

out = randerr(m) generates an m-by-m binary matrix, each row of which has exactly one nonzero entry in a random position. Each allowable configuration has an equal probability.

out = randerr(m,n) generates an m-by-n binary matrix, each row of which has exactly one nonzero entry in a random position. Each allowable configuration has an equal probability.

out = randerr(m,n,errors) generates an m-by-n binary matrix, where errors determines how many nonzero entries are in each row:

Once randerr determines the number of nonzero entries in a given row, each configuration of that number of nonzero entries has equal probability.

out = randerr(m,n,prob,state) is the same as the syntax above, except that it first resets the state of the uniform random number generator rand to the integer state.

Examples

To generate an 8-by-7 binary matrix, each row of which is equally likely to have either zero or two nonzero entries, use the command below.

To alter the scenario above by making it three times as likely that a row has two nonzero entries, use the command below instead. Notice that the second row of the error parameter sums to one.

See Also
rand, randsrc, randint


  quantiz randint