Filter coefficients for fractal noise generation
Generate Pink Noise and Obtain Allan Variance
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
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.
figure adev = sqrt(avar); loglog(tau, adev) title("Allan Deviation of Pink Noise") xlabel("\tau"); ylabel("\sigma(\tau)") grid on axis equal
Compare Fractal Noise for Various Values of Alpha
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
filter functions. Plot the generated fractal noise.
figure for ii = 1:numel(alphaValues) coef = fractalcoef(numPoles,alphaValues(ii)); fractalNoise = filter(coef.Numerator,coef.Denominator,whiteNoise); subplot(numel(alphaValues),1,ii) plot(fractalNoise) title("\alpha = " + num2str(alphaValues(ii))) end
numPoles — Number of poles
Number of poles in the filter denominator coefficients, specified as a positive integer.
alpha — Alpha value
1 (default) | scalar in range (0,2)
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 α.
coeffs — Coefficients for generating fractal noise
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.
 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.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Introduced in R2023b