This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

wgn

Generate white Gaussian noise samples

Syntax

noise = wgn(m,n,power)
noise = wgn(m,n,power,imp)
noise = wgn(m,n,power,imp,randobject)
noise = wgn(m,n,power,imp,seed)
noise = wgn(___,powertype)
noise = wgn(___,outputtype)

Description

example

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.

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

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

See Also

Functions

Introduced before R2006a