Communications Blockset | ![]() ![]() |
Generate a binary vector while controlling the number of 1s
Library
Data Sources sublibrary Comm Sources
Description
The Binary Error Pattern Generator block outputs a random binary vector whose length is the Binary vector length parameter. The Probabilities parameter helps determine how many 1s appear in each output vector. Once the number of 1s is determined, their placement is determined according to a uniform distribution.
If p1, p2,...pm are the entries in the Probabilities parameter, then p1 is the probability that the output vector will have a single 1, p2 is the probability that the output vector will have exactly two 1s, and so on. Note that Probabilities must have sum less than or equal to one, and length less than or equal to the Binary vector length. Also, the probability of a zero vector is one minus the sum of Probabilities.
This block is useful in testing error-control coding algorithms.
Initial Seed
The scalar Initial seed parameter initializes the random number generator that the block uses to generate randiom errors. For best results, the Initial seed should be a prime number greater than 30. Also, if there are other blocks in a model that have an Initial seed parameter, you should choose different initial seeds for all such blocks.
You can choose seeds for the Rician block using the Communications Blockset's randseed
function. At the MATLAB prompt, type the command
This returns a random prime number greater than 30. Typing randseed
again produces a different prime number. If you add an integer argument, randseed
always returns the same prime for that integer. For example, randseed(5)
always returns the same answer.
Attributes of Output Signal
The output signal can be a frame-based matrix, a sample-based row or column vector, or a sample-based one-dimensional array. These attributes are controlled by the Frame-based outputs, Samples per frame, and Interpret vector parameters as 1-D parameters. See Signal Attribute Parameters for Random Sources in Using the Communications Blockset for more details.
The Binary vector length parameter becomes the number of columns in a frame-based output or the number of elements in a sample-based vector output. Also, the shape (row or column) of the Probabilities parameter becomes the shape of a sample-based two-dimensional output signal.
Dialog Box
See Also
Bernoulli Binary Generator; randerr
(Communications Toolbox)
![]() | Binary Cyclic Encoder | Binary-Input RS Encoder | ![]() |