psd_tf.m 1.1 KB
clc
close all
clear all

%%
N = 1e7;
Fs = 1000;
%%

data_white.rate = Fs;
data_white.freq = noise(N, 1, 'white');
[ad_white, S, err_white, tau] = allan(data_white, 2.^[0:nextpow2(length(data_white.freq))]./Fs, 'white noise',0);
[p_white, f_white] = pwelch(data_white.freq, [], [], [], data_white.rate, 'onesided');

data_pink.rate = Fs;
data_pink.freq = noise(N, 1, 'pink');
[ad_pink, S, err_pink, tau] = allan(data_pink, 2.^[0:nextpow2(length(data_pink.freq))]./Fs, 'pink noise',0);
[p_pink, f_pink] = pwelch(data_pink.freq, [], [], [], data_pink.rate, 'onesided');


data_brown.rate = Fs;
data_brown.freq = noise(N, 1, 'brown');
[ad_brown, S, err_brown, tau] = allan(data_brown, 2.^[0:nextpow2(length(data_brown.freq))]./Fs, 'brown noise',0);
[p_brown, f_brown] = pwelch(data_brown.freq, [], [], [], data_brown.rate, 'onesided');

figure
hold on
loglogerr(tau, ad_white, err_white, 'b')
loglogerr(tau, ad_pink, err_pink, 'm')
loglogerr(tau, ad_brown, err_brown, 'k')
grid on

figure
hold on
semilogx(f_white, 10*log10(p_white), 'b')
semilogx(f_pink, 10*log10(p_pink), 'm')
semilogx(f_brown, 10*log10(p_brown), 'k')
grid on