![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1362778/image.png)
How to compute Allan Variance without allanvar?
28 次查看(过去 30 天)
显示 更早的评论
Hi,
I would like to compute the Allan Variance to study a signal but without the existing Matlab function. Actually I wanted to see how matlab computes it but we don't have access to it (*.p file, btw I wonder why this function is not accessible?).
Actually I have a good article ( Techniques Ingénieur, VERNOTTE, R681) Stabilité temporelle et fréquentielle des oscillateurs : outils d’analyse that gives all the basics to compute by hand the Allan Variance.
I tried to reproduce the result displayed at the allanvar matlab page but I didn't manage. I don't have the trend as the figure displayed. Can anyone take a look at my code? Maybe i mistyped the formula? My
function is:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1344849/image.png)
function out = AllanVar(sig,n,dt)
y1 = sum(sig(1:1+n));
y2 = sum(sig(2:2+n));
out = (y2-y1)^2/2/(n*dt)^2;
end
And to remove the noise we can average it over multiple draws with:
numSamples = 1e6;
Pow = nextpow2(numSamples)-1;
N = 100;
m = 2.^(1:Pow);
aVar = zeros(N,length(m));
for k = 1:N
Fs = 100;
nStd = 1e-3;
kStd = 1e-7;
nNoise = nStd.*randn(numSamples,1);
kNoise = kStd.*cumsum(randn(numSamples,1));
omega = nNoise+kNoise;
for j = 1:length(m)
aVar(k,j) = AllanVar(omega,m(j),1/Fs);
end
end
tau = m*dt;
figure
loglog(tau,sqrt(mean(aVar)),'k')
But I get a straight line only...
Attached an output figure. Thanks in advance! :)
0 个评论
采纳的回答
Gokul Nath S J
2023-4-21
Hi Louis,
I understood that the allanvariance file is in .p format and you don't have access to it. However, there is a MATALB Exchange file for computing allan deviation which is defined as,
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1362778/image.png)
So part from the square root step, rest of the calcuation remains the same.
Kindly find the attachement MATALB Exchange document for more information.
Thanks,
Gokul Nath S J
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!