top of page

Creating White Noise in MATLAB: A Step-by-Step Guide

Jan 23, 2024

White noise is a random signal characterized by a constant power spectral density. In various applications like audio processing and communications, it can be highly useful to generate white noise. This article will guide you through the process of generating white noise in MATLAB, a popular computing and programming platform that allows for easy manipulation of matrices and mathematical functions.

Step 1: Defining Parameters
Before generating the white noise, it's important to define certain parameters such as the noise duration and sampling frequency. Here's an example:

% Noise duration (in seconds)
T = 1;

% Sampling Frequency (in Hertz)
fs = 44100;

Step 2: Generating the Random Signal
The next step is to create a vector with random values that will represent the white noise signal. MATLAB allows you to do this easily with the 'randn' function, which creates random numbers from a standard normal distribution (mean = 0 and standard deviation = 1).

% Generate random signal
y = randn(1, T * fs);

Step 3: Scaling the Signal
To control the amplitude or volume of the white noise signal, it's necessary to scale it to the desired level. To do this, simply multiply the signal by a scaling factor:

% Scaling factor
scale = 0.1;

% Scale the signal
y = y * scale;

Step 4: Playing the White Noise Signal
Now that the white noise signal is generated, you may want to listen to it. MATLAB provides the 'sound' function for this purpose. Here's how it's done:

% Play the white noise
sound(y, fs);

That's it! You have now successfully generated and played white noise in MATLAB. The 'randn' function is a powerful tool for generating white noise, making it easy for users to apply it to their projects and applications.

bottom of page