adev_averaging.m
987 Bytes
clc
close all
clear all
Ts = 0.2;
N = 1e6;
D = 5;
data_raw.rate = 1/Ts;
data_raw.freq = 1/2.*noise(N, 1, 'white') + 1.*noise(N, 1, 'pink') + 1.*noise(N, 1, 'brown') + 0e-8.*[0:N-1]';
t_raw = [0:length(data_raw.freq)-1];
[ad_raw, S, err_raw, tau_raw] = allan(data_raw, 2.^[0:20].*Ts, 'raw',0);
data_avg.rate = 1/(Ts*D);
data_avg.freq = mean(reshape(data_raw.freq', [D, N/D]))';
t_avg = D.*[1:length(data_avg.freq)];
[ad_avg, S, err_avg, tau_avg] = allan(data_avg, 2.^[0:20].*Ts*D, 'avg',0);
data_decim.rate = 1/(Ts*D);
data_decim.freq = reshape(data_raw.freq', [D, N/D])(1,:)';
t_decim = D.*[0:length(data_decim.freq)-1];
[ad_decim, S, err_decim, tau_decim] = allan(data_decim, 2.^[0:20].*Ts*D, 'decim',0);
figure
hold on
loglogerr(tau_raw, ad_raw, err_raw, 'b')
loglogerr(tau_decim, ad_decim, err_decim, 'm')
loglogerr(tau_avg, ad_avg, err_avg, 'r')
grid on
figure
hold on
plot(t_raw, data_raw.freq, 'b')
plot(t_decim, data_decim.freq, 'm')
plot(t_avg, data_avg.freq, 'r')
grid on