Blame view
allanplot.m
2.12 KB
b197c3fdf first commit |
1 |
#!/usr/bin/octave-cli --persist |
54ec4ada0 add help header |
2 3 4 5 6 7 8 9 |
# allanplot.m computes Allan deviation from temporal dataset # # use : allanplot.m file.dat column_i gain_i ad_opt # allanplot.m file.dat [column_i,column_j] [gain_i,gain_j] [ad_opt_i,ad_opt_j] # # inputs: # file.dat : [string] file to load # columns : int or [int] columns to load |
b25b94030 add fs arg and re... |
10 |
# fs : int or [int] sampling frequency |
54ec4ada0 add help header |
11 12 13 14 15 16 |
# gains : float or [float] gains to apply # ad_opt : int or [int] ad options : # 0 direct allan computation # 1 drift removed ad # 2 relative ad # 3 relative drift removed ad |
7bd874638 allanplot.m: add ... |
17 18 19 |
# arg_save : [int] save adev with one file per column : # 0 without save # 1 save adev result to file-col.sig |
54ec4ada0 add help header |
20 |
|
b197c3fdf first commit |
21 22 |
filename = argv(){1}; col = eval(argv(){2}); |
b25b94030 add fs arg and re... |
23 24 25 |
fs = eval(argv(){3}); mult = eval(argv(){4}); ad_opt = eval(argv(){5}); |
7bd874638 allanplot.m: add ... |
26 |
arg_save = eval(argv(){6}); |
b197c3fdf first commit |
27 |
|
2f13b7356 add multiple colu... |
28 |
if length(col) == length(mult) |
1a0e88f0c replace 4-spaces ... |
29 30 31 32 33 34 |
figure hold all grid on cc = 'bkcgmry'; for i = [1:length(col)] data.freq = load(filename)(:,col(i)).*mult(i); |
7420f56d6 add sample time arg |
35 |
if nargin == 5 |
54ec4ada0 add help header |
36 |
if ad_opt(i) == 1 |
1a0e88f0c replace 4-spaces ... |
37 38 39 40 |
printf(strcat(filename, ' col', num2str(col(i)), ' drift removed ')) data.freq = detrend(data.freq); |
54ec4ada0 add help header |
41 |
elseif ad_opt(i) == 2 |
4a63914c1 add relative ad o... |
42 43 44 |
printf(strcat(filename, ' col', num2str(col(i)), ' relative ad : mean=', num2str(mean(data.freq)), ' ')) |
b25b94030 add fs arg and re... |
45 46 47 48 49 50 |
data.freq = data.freq./mean(data.freq); elseif ad_opt(i) == 3 printf(strcat(filename, ' col', num2str(col(i)), ' drift removed relative ad ')) data.freq = detrend(data.freq./mean(data.freq)); |
1a0e88f0c replace 4-spaces ... |
51 52 |
end endif |
b25b94030 add fs arg and re... |
53 |
data.rate = fs(i); |
b12818783 use log repeated ... |
54 |
[ad, S, err, tau] = allan(data, horzcat(reshape([1:0.1:9]'.*10.^[0:round(log10(length(data.freq)))-1],1,[]), 10^(round(log10(length(data.freq)))-1))./data.rate, strcat(strsplit(filename, '/'){end}, num2str(i)), 0); |
1a0e88f0c replace 4-spaces ... |
55 56 57 58 |
loglogerr(tau, ad, err, strcat(cc(mod(i, length(cc))), '-s')) leg{i} = strcat(filename, ' col', num2str(col(i))); axis(10.^ceil(log10([tau(1), tau(end)]))) hold on |
7bd874638 allanplot.m: add ... |
59 60 61 62 63 |
if arg_save ==1 filenameout = strcat(strsplit(filename,'.'){1},'-',num2str(col(i)),'.sig') datatosave = horzcat(tau', ad', err'); save('-ascii', filenameout , 'datatosave'); end |
1a0e88f0c replace 4-spaces ... |
64 65 66 |
end legend(leg) input("Press to continue..."); |
2f13b7356 add multiple colu... |
67 |
end |
b197c3fdf first commit |
68 |
exit |