noisegen1D is a coloring tool allowing the generation of colored noise from withe noise with a given spectrum. The function constructs a coloring filter through a fitting procedure to the model provided. If no model is provided an error is prompted. The colored noise provided has one-sided psd corresponding to the input model.
b = noisegen1D(a, pl);
[b1,b2,...,bn] = noisegen1D(a1,a2,...,an, pl);
%% Noise generation from fsdata model object %%%%%%%%%%%%%%%%%%%%%%%%%%%
% Description:
% 1) Generate a fsdata object to be used as psd model
% 2) Generate a random series of data (white)
% 3) Generate colored noise with noisegen1D
% 4) calculated psd of generated data
% 5) check result by plotting
% 1)
fs = 10; % sampling frequency
pl_mod1 = plist('fsfcn', '0.01./(0.01+f)', 'f1', 1e-6, 'f2', 5, 'nf', 100);
mod1 = ao(pl_mod1); % fsdata model object
% 2)
% generating white noise
a1 = ao(plist('tsfcn', 'randn(size(t))', 'fs', fs, 'nsecs', 1000));
% 3) Noise generation
pl1 = plist(...
'model', mod1, ...
'MaxIter', 30, ...
'PoleType', 2, ...
'MinOrder', 10, ...
'MaxOrder', 20, ...
'Weights', 2, ...
'Plot', false,...
'Disp', false,...
'RMSEVar', 5,...
'FitTolerance', 2);
ac1 = noisegen1D(a1, pl1);
% 4)
acxx1 = ac1.psd;
% 5)
iplot(acxx1, mod1);