Communications Toolbox    

Random Signals

Random signals are useful for simulating noise, errors, or signal sources. Besides built-in MATLAB functions like rand and randn, you can also use these functions from this toolbox:

While randsrc and randint are suitable for representing sources, randerr is more appropriate for modeling channel errors.

White Gaussian Noise

The wgn function generates random matrices using a white Gaussian noise distribution. You specify the power of the noise in either dBW (decibels relative to a watt), dBm, or linear units. You can generate either real or complex noise.

For example, the command below generates a column vector of length 50 containing real white Gaussian noise whose power is 2 dBW. The function assumes that the load impedance is 1 ohm.

To generate complex white Gaussian noise whose power is 2 Watts, across a load of 60 ohms, use either of the commands below. Notice that the ordering of the string inputs does not matter.

To send a signal through an additive white Gaussian noise channel, use the awgn function.

Random Symbol Matrices

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.)

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.

Random Integer Matrices

The randint function generates random integer matrices whose entries are in a range that you specify. A special case generates random binary matrices.

For example, the command below generates a 5-by-4 matrix containing random integers between 2 and 10.

If your desired range is [0,10] instead of [2,10] then you can use either of the commands below. They produce different numerical results, but use the same distribution.

Random Bit Error Patterns

The randerr function generates matrices whose entries are either 0 or 1. However, its options are rather different from those of randint, because randerr is meant for testing error-control coding. For example, the command below generates a 5-by-4 binary matrix having the property that each row contains exactly one 1.

You might use such a command to perturb a binary code that consists of five four-bit codewords. Adding the random matrix f to your code matrix (modulo 2) would introduce exactly one error into each codeword.

On the other hand, if you want to perturb each codeword by introducing one error with probability 0.4 and two errors with probability 0.6, then the command below should replace the one above.

As another application, you can generate an equiprobable binary 100-element column vector using any of the commands below. The three commands produce different numerical outputs, but use the same distribution. Notice that the third input arguments vary according to each function's particular way of specifying its behavior.


  Random Signals and Error Analysis Error Rates