Allan Variance (allanvar) not working correctly

6 次查看(过去 30 天)
I'm having an issue with using the allanvar function and I'm not sure if it is a bug or if I'm using the function incorrectly. The documentation states that if a matrix is supplied on input, then the Allan variance is evaluated over the columns.
In the following code, I compute the Allan variance two different ways for a matrix. In the first case, I'm using a loop over the columns. In the second case, I'm just sending the whole matrix in as input. I expect them to produce the same result, but they do not. When I send the whole matrix in, I'm finding that there are many zeros being returned, which does not happen when I evaluate the Allan variance in a loop. Any explanations?
% Test angle random walk
rng('default')
close all
clear
% Gyro angle random walk specification (deg / sqrt(sec))
angleRandomWalk = 0.001;
% Time step between gyro measurements (sec)
Fs = 100;
dt = 1 / Fs;
% Generate gyro random walk samples
nTime = 100000;
mMonteCarlo = 1000;
randomWalk = angleRandomWalk / sqrt(dt) * randn(nTime, mMonteCarlo);
% Time vector
t = [0:nTime-1]' / Fs;
% Integrate random walk rates over time to angle
angle = cumsum( randomWalk * dt );
% Allan Variance - the square root of the Allan Variance at t = 1 sec should
% equal the angleRandomWalk.
% Time points for evaluating Allan Variance
tm = [ 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 2 3 4 5 6 7 8 9 10 20 30 40 50 60 70 80 90 100 200 300 400 ]';
[~, m ] = intersect(t, tm);
aVar = zeros(length(m), mMonteCarlo);
for n = 1:mMonteCarlo
[aVar(:,n), tau] = allanvar(randomWalk(:,n), m, Fs);
end
[aVar2, tau2] = allanvar(randomWalk, m, Fs);
% Compute the mean of the square root of the Allan Variance at t = 1 second (should equal
% the angleRandomWalk).
rootAllanVar = mean( sqrt( aVar(10, :) ) );
rootAllanVar2 = mean( sqrt( aVar2(10, :) ) );

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

产品


版本

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by