| Communications Toolbox | ![]() |
The randsrc function generates random matrices whose entries are chosen independently from an alphabet that you specify, with a distribution that you specify. A special case generates bipolar matrices.
For example, the command below generates a 5-by-4 matrix whose entries are independently chosen and uniformly distributed in the set {1,3,5}. (Your results might vary because these are random numbers.)
a = randsrc(5,4,[1,3,5])
a =
3 5 1 5
1 5 3 3
1 3 3 1
1 1 3 5
3 1 1 3
If you want 1 to be twice as likely to occur as either 3 or 5, then use the command below to prescribe the skewed distribution. Notice that the third input argument has two rows, one of which indicates the possible values of b and the other indicates the probability of each value.
b = randsrc(5,4,[1,3,5; .5,.25,.25])
b =
3 3 5 1
1 1 1 1
1 5 1 1
1 3 1 3
3 1 3 1
| White Gaussian Noise | Random Integers | ![]() |
© 1994-2005 The MathWorks, Inc.