Main Content


Filter coefficients for fractal noise generation

Since R2023b


coeffs = fractalcoef returns the filter coefficients for generating fractal noise with a power spectral density of 1/f, where f is the frequency. For more information on noise filtering, see filter.


You can use the generated coefficients to specify the BiasInstabilityCoefficients property of the accelparams, gyroparams, or magparams object.


coeffs = fractalcoef(numPoles) specifies the number of poles in the filter denominator coefficients.


coeffs = fractalcoef(numPoles,alpha) also specifies the alpha value (α) for the fractal noise with a power spectral density of 1/f α. When α = 1, the generated noise is also known as pink noise.


collapse all

First specify the frequency, number of samples, and number of poles for noise generation.

rng default % For repeatable results
Fs = 100;
numSamples = 2160000;
numPoles = 5;

Obtain filter coefficients using the fractalcoef function.

coeffs = fractalcoef(numPoles);

Generate white noise and filter the noise to obtain pink noise.

wn = randn(numSamples,1);
pn = filter(coeffs.Numerator,coeffs.Denominator,wn);

Generate Allan variance of the pink noise.

[avar,tau] = allanvar(pn,"octave",Fs);

Plot Allan deviation of the pink noise.

adev = sqrt(avar);
loglog(tau, adev)
title("Allan Deviation of Pink Noise")
grid on
axis equal

Define the number of samples, number of poles, and alpha values used to generate fractal noise.

rng default % For repeatable results
numSamples = 1e4;
numPoles = 1e3;
alphaValues = [0.1,0.5,1,1.5,1.9];

Create a series of white noise.

whiteNoise = randn(numSamples,1);

Generate fractal noise with different values of alpha using the fractalcoef and filter functions. Plot the generated fractal noise.

for ii = 1:numel(alphaValues)
    coef = fractalcoef(numPoles,alphaValues(ii));
    fractalNoise = filter(coef.Numerator,coef.Denominator,whiteNoise);
    title("\alpha = " + num2str(alphaValues(ii)))

Input Arguments

collapse all

Number of poles in the filter denominator coefficients, specified as a positive integer.

Example: 2

Data Types: single | double

Alpha value (α), specified as a scalar in the range (0,2). The function returns the coefficients for generating fractal noise with a power spectral density of 1/f α.

Example: 0.9

Data Types: single | double

Output Arguments

collapse all

Coefficients for generating fractal noise, returned as a structure. The structure has two fields:

  • Numerator — Numerator of coefficients, returned as 1.

  • Denominator — Denominator of coefficients, returned as a 1-by-(P+1) vector of scalars, where P is the number of poles.


[1] Kasdin, N. J. “Discrete Simulation of Colored Noise and Stochastic Processes and 1/fα Power Law Noise Generation.” Proceedings of the IEEE, vol. 83, no. 5, May 1995, pp. 802–27.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2023b