Probably the easiest way is to create a FIR filter that has a ‘1/f’ passband, then filter random noise through it:
fv = linspace(0, 1, 20);
a = 1./(1 + fv*2);
b = firls(42, fv, a);
figure(1)
freqz(b, 1, 2^17)
N = 1E+6;
ns = rand(1, N);
invfn = filtfilt(b, 1, ns);
figure(2)
plot([0:N-1], invfn)
grid
FTn = fft(invfn-mean(invfn))/N;
figure(3)
plot([0:N/2], abs(FTn(1:N/2+1))*2)
grid
It uses the firls function to design a FIR filter that closely matches the ‘1/f’ passband. See the documentation on the various functions to get the result you want.
Note: The filter is normalised on the open interval (0,1), corresponding to (0,Fn) where ‘Fn’ is the Nyquist frequency, or half your sampling frequency. It should work for any sampling frequency that you want to use with it.
This should get you started. Experiment to get the result you want.
Best Answer