1% =========================================================================== %
2%> @brief performs a noise analysis of data of a JUMP sensor.
4%>
this function performs an Allan Deviation analysis of the data of a JUMP
5%> sensor. The data is expected to be in the format of the JUMP sensor data
6%> structure defined in @ref
jumpReadData.m. The function an
interface between
9%> @param data (
struct): the data of a JUMP sensor in the format of the JUMP
11%> @param options (struct): options for the analysis
12%> - toAnalyze (string): the fields of the data to analyze (default: [
"acc",
"gyr",
"hig",
"mag",
"prs",
"tmp"])
13%> - plot (logical): if true, the function will plot the Allan Deviation of the data (default: false)
15%> @retval analysis (struct): a struct with the results of the analysis. The
16%> struct has the same fields as the input data, and each field has the
17%> following subfields:
18%> - tau (double): the tau values of the Allan Deviation
19%> - adev (double): the Allan Deviation values
20%> - N (double): the Power Spectral Density
21%> - K (double): the K value of the Allan Deviation
22%> - B (double): the B value of the Allan Deviation
23%> - tau_B (double): the tau value of the B value
24%> - note (string): a note about the units of the results
28%> @copyright see the file @ref LICENSE in the root directory of the repository
29% =========================================================================== %
35 options.toAnalyze (1,:) string = [
"acc",
"gyr",
"hig",
"mag",
"prs",
"tmp"];
36 options.plot (1,:) logical = false;
46 figure(
"Name", sprintf(
"Allan Deviation Analysis of Sensor %s",
char(data.name)),
"NumberTitle",
"off");
50for i = 1:length(options.toAnalyze)
52 dataToAnalyze = data.tt.(options.toAnalyze(i));
55 if strcmp(options.toAnalyze(i),
"acc") || strcmp(options.toAnalyze(i),
"gyr")
57 elseif strcmp(options.toAnalyze(i), "mag")
59 this_idx = all(~isnan(data.tt.mag),2);
61 this_times = data.tt.t(this_idx);
62 fs = round(1 / seconds(median(diff(this_times))));
65 % no timing correction was applied, therefore use 10 Hz
69 % downsampe because the data is stored at mpu_rate, but the actual rate is 10 Hz
70 dataToAnalyze = resample(dataToAnalyze(this_idx,:), this_times, fs, "pchip");
72 elseif strcmp(options.toAnalyze(i), "hig")
74 elseif strcmp(options.toAnalyze(i), "prs") || strcmp(options.toAnalyze(i), "tmp")
76 this_idx = all(~isnan(data.tt.(options.toAnalyze(i))),2);
78 this_times = data.tt.t(this_idx);
79 fs = round(1 / seconds(median(diff(this_times))));
81 if fs >= data.pres_rate * 2
82 % no timing correction was applied, therefore use 1 Hz
86 % downsampe because the data is stored at mpu_rate, but the actual rate is pres_rate
87 dataToAnalyze = resample(dataToAnalyze(this_idx,:), this_times, fs, "pchip");
93 analysis.(options.toAnalyze(i)).tau = tau;
94 analysis.(options.toAnalyze(i)).adev = adev;
95 analysis.(options.toAnalyze(i)).N = N;
96 analysis.(options.toAnalyze(i)).K = K;
97 analysis.(options.toAnalyze(i)).B = B;
98 analysis.(options.toAnalyze(i)).tau_B = tau_B;
99 analysis.(options.toAnalyze(i)).note = "The units are related to the input data. Check units before applying them to a model. Also, the Power Spectral Density (N) is outputtet according to single sided spectrum.";
104 subplot(2,ceil(length(options.toAnalyze)/2),i);
106 loglog(tau, adev, '-r', 1, N, 'o', 3, K, 'x', tau_B, 0.664*B, '+');
107 title(options.toAnalyze(i));
109 ylabel('Allan Deviation');
function allanDeviationAnalysis(in meas, in fs)
function jumpCheckData(in data)
function jumpNoiseAnalysis(in data, in options)
function jumpReadData(in filePath, in options)