-
Notifications
You must be signed in to change notification settings - Fork 5
/
Translation_Boxplot.m
executable file
·75 lines (67 loc) · 1.95 KB
/
Translation_Boxplot.m
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
75
function out = Translation_Boxplot(f, t)
% TRANSLATION_BOXPLOT Translation Boxplot
% -------------------------------------------------------------------------
% This function constructs the translation boxplot
%
% Usage: out = Translation_Boxplot(f, t)
%
% Input:
% f (M,N): matrix defining N functions of M samples
% t : time vector of length M
%
% Output: structure containing
% median_t: median translation
% Q1: First quartile
% Q3: Second quartile
% minn: minimum extreme function
% maxx: maximum extreme function
% outlier_index: indexes of outlier functions
figure(100);clf;
plot(t,f,'linewidth',2);
set(gca,'FontSize',19);
ti = get(gca,'TightInset');
set(gca,'Position',[ti(1) ti(2) 1-ti(3)-ti(1) 1-ti(4)-ti(2)]);
[~, N] = size(f);
translation = zeros(1,N);
for i = 1:N
translation(i) = trapz(t,f(:,i)) / (t(end) - t(1));
end
figure(200);clf;
h=boxplot(translation);
set(h,'LineWidth',2);
set(gca,'FontSize',19);
ti = get(gca,'TightInset');
set(gca,'Position',[ti(1) ti(2) 1-ti(3)-ti(1) 1-ti(4)-ti(2)]);
h = findobj(gca,'Type','line');
m = get(h(2), 'YData');
LW = get(h(6), 'YData');
UW = get(h(7), 'YData');
minn = LW(1); Q1 = LW(2); median_t = m(1); Q3 = UW(1); maxx = UW(2);
outlier = get(h(1), 'YData');
% outliers
if isnan(outlier)
outlier = [];
outlier_index = [];
else
outlier_index = zeros(1,length(outlier));
for i = 1:length(outlier)
outlier_index(i) = find(translation == outlier(i));
figure(200+i);clf;
plot(t,f,'green','linewidth',2);
hold on;
plot(t,f(:,outlier_index(i)),'red','linewidth',2);
xlim([t(1) t(end)]);
ylim auto;
set(gca,'FontSize',19)
ti = get(gca,'TightInset');
set(gca,'Position',[ti(1) ti(2) 1-ti(3)-ti(1) 1-ti(4)-ti(2)]);
end
end
out.time = t;
out.f = f;
out.median_t = median_t;
out.Q1 = Q1;
out.Q3 = Q3;
out.minn = minn;
out.maxx = maxx;
out.outlier_index = outlier_index;