top of page

Generating White Noise in MATLAB: A Comprehensive Guide

Jan 23, 2024

In the digital world, white noise plays a significant role in various applications such as audio processing, data analysis, and random signal generation. In this article, we will walk you through the process of generating white noise in MATLAB, a prevalent and widely-used programming environment for technical computing.

What is White Noise?

White noise is a random signal with equal intensity at different frequencies, giving it a constant power spectral density. It is called 'white' because it combines all frequencies, much like white light combines all wavelengths of visible light. In terms of sound, white noise will produce a hissing effect when played.

Generating White Noise in MATLAB

The process of generating white noise in MATLAB is quite simple and straightforward. Follow these steps to create white noise in this computing environment:

  1. Open MATLAB on your computer.

  2. In the MATLAB command window, type the following command to generate white noise:

    y = wgn(m, n, p);

Here, 'y' is the output white noise signal, 'm' and 'n' are the dimensions (rows and columns) of the generated signal, and 'p' represents the power of white noise in decibels relative to one milliwatt (dBm).

For example, to create a 1x5000 array of white noise with a power of 0 dBm, type:

y = wgn(1, 5000, 0);
  1. To play the generated white noise sound, use the 'sound' function:

    sound(y, Fs);

In this command, 'Fs' is the sampling frequency in Hertz (Hz). For example, to play the white noise at a sample rate of 44,100 Hz, type:

sound(y, 44100);
  1. To visualize the generated white noise signal, you can plot it using the 'plot' function:

    plot(y);

  2. To analyze the power spectral density of the generated white noise, you can use the 'pwelch' function:

    [Pxx, F] = pwelch(y);
    plot(F, 10*log10(Pxx));

In this example, 'Pxx' represents the power spectral density, 'F' is the frequency vector, and the resulting plot will show the power spectral density in dB/Hz.

By following these simple steps, you can generate and analyze white noise in MATLAB. The versatile nature of MATLAB allows you to further manipulate the white noise signal for any desired application, such as filtering, modulation, and additional processing.

bottom of page