-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalyze_errors.m
More file actions
74 lines (58 loc) · 1.94 KB
/
analyze_errors.m
File metadata and controls
74 lines (58 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
errorfile = 'errors/path_1_long_23_10_31_06_27_14.csv';
close all;
drifts = readmatrix(errorfile);
%interval = 20;
%plot_drifts(drifts, interval, 'm');
%interval = 40;
%plot_drifts(drifts, interval, 'r');
%interval = 60;
%plot_drifts(drifts, interval, 'y');
%interval = 75;
%plot_drifts(drifts, interval, 'g');
%interval = 100;
%plot_drifts(drifts, interval, 'c');
%interval = 120;
%plot_drifts(drifts, interval, 'm');
%interval = 145;
%plot_drifts(drifts, interval, 'r');
interval = 170;
plot_drifts(drifts, interval, 'b');
function plot_drifts(drifts, interval, colorArg)
colorArray = ['r', 'g', 'b', 'c', 'm', 'y', 'k'];
colorArray = repmat(colorArray, 1, 10);
for i = 1:interval*floor(length(drifts)/interval)
if nargin <= 2
color = colorArray(floor(i/interval)+1);
else
color = colorArg;
end
hold on;
plot(drifts(1, i), drifts(2, i), 'o', 'Color', color);
if mod(i, interval) == 1
%disp(interval*floor(i/interval)+1:interval*floor(i/interval)+interval);
[xmid, xlow, xhigh, ymid, ylow, yhigh] = calculate_bounds(drifts(:, interval*floor(i/interval)+1:interval*floor(i/interval)+interval));
plotcircle(xmid, xlow, xhigh, ymid, ylow, yhigh, color);
end
hold off;
end
end
function [xmid, xlow, xhigh, ymid, ylow, yhigh] = calculate_bounds(data)
bound_percentile = 95;
xmid = median(data(1, :));
ymid = median(data(2, :));
xlow = prctile(data(1, :), 100-bound_percentile);
xhigh = prctile(data(1, :), bound_percentile);
ylow = prctile(data(2, :), 100-bound_percentile);
yhigh = prctile(data(2, :), bound_percentile);
end
function plotcircle(xmid, xlow, xhigh, ymid, ylow, yhigh, color)
% Calculate the semi-major and semi-minor axes lengths
a = (xhigh - xlow) / 2;
b = (yhigh - ylow) / 2;
% Calculate the center of the ellipse
x_center = xmid;
y_center = ymid;
% Plot the ellipse
rectangle('Position', [x_center - a, y_center - b, 2 * a, 2 * b], ...
'Curvature', [1, 1], 'EdgeColor', color);
end