Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English version of the page.

# allanvar

Allan variance

## Syntax

[avar,tau] = allanvar(omega)
[avar,tau] = allanvar(omega,m)
[avar,tau] = allanvar(omega,ptStr)
[avar,tau] = allanvar(___,fs)

## Description

[avar,tau] = allanvar(omega) returns the Allan variance avar as a function of sample length tau. If omega is specified as a matrix, allanvar operates over the columns of omega.
[avar,tau] = allanvar(omega,m) returns the Allan variance for specific values of τ, defined by m.
[avar,tau] = allanvar(omega,ptStr) sets tau to the specified ptStr. 

example

[avar,tau] = allanvar(___,fs) specifies the sample rate of omega at fs Hz. This input parameter can be used with any of the previous syntaxes.

## Examples

collapse all

Load gyroscope data from a MAT file, including the sample rate of the data in Hz. Calculate the Allan variance.

load('LoggedSingleAxisGyroscope','omega','Fs') [avar,tau] = allanvar(omega,'octave',Fs);

Plot the Allan variance on a loglog plot.

loglog(tau,avar) xlabel('\tau') ylabel('\sigma^2(\tau)') title('Allan Variance') grid on

Generate sample gyroscope noise, including angle random walk and rate random walk.

numSamples = 1e6; Fs = 100; nStd = 1e-3; kStd = 1e-7; nNoise = nStd.*randn(numSamples,1); kNoise = kStd.*cumsum(randn(numSamples,1)); omega = nNoise+kNoise;

Calculate the Allan deviation at specific values of $\mathit{m}=\tau$. The Allan deviation is the square root of the Allan variance.

m = 2.^(9:18); [avar,tau] = allanvar(omega,m,Fs); adev = sqrt(avar);

Plot the Allan deviation on a loglog plot.

loglog(tau,adev) xlabel('\tau') ylabel('\sigma(\tau)') title('Allan Deviation') grid on

## Input Arguments

collapse all

Input array specified as a vector, matrix, or multidimensional array. If specified as a matrix, allanvar operates over the columns of omega.

Data Types: single | double

Specific values of τ at which to calculate Allan variance, specified as a scalar or vector with ascending integer values less than (N-1)/2, where N is the number of elements in omega. m is not the index of omega.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Point specification of tau, specified as:

• 'octave'

$\left[{2}^{0},{2}^{1}{...2}^{⌊{\mathrm{log}}_{2}\left(\frac{N-1}{2}\right)⌋}\right]$
• 'decade'

$\left[{10}^{0},{10}^{1}{...10}^{⌊{\mathrm{log}}_{10}\left(\frac{N-1}{2}\right)⌋}\right]$

N is the number of samples in omega.

Sample rate of input array in Hz, specified as a positive scalar.

Data Types: single | double

## Output Arguments

collapse all

Allan variance of input array at tau, specified as a vector, matrix, or multidimensional array.

Sample lengths corresponding to values of output. Specify this parameter by octave or decade using ptStr.

## Algorithms

Allan variance can be used to measure the frequency stability of precision oscillators or identify sources of noise in gyroscope data. Consider N samples of data from a gyroscope with a sample time of τ0. Form data clusters of durationsτ0, 0, …, 0, where m is less than half of N. Then, obtain the averages of the sum of the data points contained in each cluster over the length of the cluster. The Allan variance is defined as the two-sample variance of the data cluster averages as a function of cluster time. This function calculates overlapping Allan variance.