top of page

Generating White Noise in MATLAB: Standard Deviation Edition

May 17, 2024

If you're looking to generate white noise in MATLAB using a specific standard deviation, you've come to the right place. White noise is a random signal with equal intensity across different frequencies, making it ideal for various applications such as audio testing, signal processing, and more.


In this tutorial, we'll show you how to create white noise In this tutorial, we'll show you how to create white noise In this tutorial, we'll show you how to create white noise In this tutorial, we'll show you how to create white noise In this tutorial, we'll show you how to create white noise In this tutorial, we'll show you how to create white noise with a specified standard deviation in MATLAB.


Step 1: Define Parameters


First, you need to define the parameters for your white noise signal. Specify the length of the signal (N), the sampling frequency (Fs), and the standard deviation (st_dev).


N = 10000; % Signal length
Fs = 1000; % Sampling frequency
st_dev = 3; % Standard deviation

Step 2: Generate White Noise


Now that you've set your parameters, you can generate the white noise signal by using MATLAB's randn function. This function generates random numbers with a mean value of 0 and a standard deviation of 1. To achieve your desired standard deviation, multiply the output of randn by your standard deviation value (st_dev).


white_noise = st_dev * randn(1, N);

Step 3: Analyze the White Noise Signal


To check if your generated white noise signal has the correct standard deviation, you can calculate its mean, variance, and power spectral density.


mean_val = mean(white_noise);
var_val = var(white_noise);
[pow_spec, freq] = periodogram(white_noise, [], N, Fs);

Display the results:


fprintf('Mean Value: %f
', mean_val);
fprintf('Variance: %f ', var_val);
plot(freq, pow_spec);
xlabel('Frequency (Hz)');
ylabel('Power Spectral Density');
title('Periodogram of White Noise');
grid on;

This should display the mean value (close to 0), the variance (close to the square of the standard deviation), and the power spectral density of the generated white noise signal.


You have now successfully generated white noise in MATLAB using a specified standard deviation.


bottom of page