Main Content

wgn

Generate white Gaussian noise samples

Description

noise = wgn(m,n,power) generates an m-by-n matrix of white Gaussian noise samples in volts. power specifies the power of noise in dBW.

example

noise = wgn(m,n,power,imp) specifies the load impedance in ohms.

noise = wgn(m,n,power,imp,randobject) specifies a random number stream object to use when generating the matrix of white Gaussian noise samples. For information about producing repeatable noise samples, see Tips.

noise = wgn(m,n,power,imp,seed) specifies a seed value for initializing the normal random number generator that is used when generating the matrix of white Gaussian noise samples. For information about producing repeatable noise samples, see Tips.

noise = wgn(___,powertype) specifies the units of power as 'dBW', 'dBm', or 'linear' in addition to the input arguments in any of the previous syntaxes.

noise = wgn(___,outputtype) specifies the output type as 'real' or 'complex' in addition to the input arguments in any of the previous syntaxes.

Examples

collapse all

Generate real and complex white Gaussian noise (WGN) samples. Check the power of output WGN matrices.

Generate a 1000-element column vector of real WGN samples and confirm that the power is approximately 1 watt, which is 0 dBW.

y1 = wgn(1000,1,0);
var(y1)
ans = 
0.9979

Generate a 1000-element column vector of complex WGN samples and confirm that the power is approximately 0.25 watts, which is –6 dBW.

y2 = wgn(1000,1,-6,'complex');
var(y2)
ans = 
0.2521

Input Arguments

collapse all

Number of white Gaussian noise samples desired per channel, specified as a positive integer.

Data Types: double

Number of channels of white Gaussian noise samples desired, specified as a positive integer.

Data Types: double

Power of noise samples, specified as a scalar. The default units for power is dBW. Use powertype to change the units of power.

Data Types: double

Load impedance in ohms, specified as a scalar.

Data Types: double

Random number stream object, specified as a RandStream object. The state of the random stream object determines the sequence of numbers produced by the randn function. Configure the random stream object using the reset (RandStream) function and its properties.

wgn generates normal random noise samples using randn. The randn function uses one or more uniform values from the RandStream object to generate each normal value.

For information about producing repeatable noise samples, see Tips.

Random number generator seed, specified as a nonnegative integer. For more information on the random number generator, see randn.

Signal power unit, specified as 'dBW', 'dBm', or 'linear'. Linear power is in watts.

Output type, specified as 'real' or 'complex'. If outputtype is 'complex', then the real and imaginary parts of noise each have a noise power of (power / 2).

Output Arguments

collapse all

Output white Gaussian noise samples in volts, returned as an m-by-n matrix.

Note

Unless the default impedance for imp is changed, a load of 1 ohm is used for power calculations.

Tips

  • To generate repeatable white Gaussian noise samples, use one of these tips:

    • Provide a static seed value as an input to wgn.

    • Use the reset (RandStream) function on the randobject before passing it as an input to wgn.

    • Provide randobject in a known state as an input to wgn. For more information, see RandStream.

Extended Capabilities

Version History

Introduced before R2006a

See Also

Functions