-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsubslider.m
131 lines (115 loc) · 3.77 KB
/
subslider.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
function subslider(histy)
clf
% x and y are the histogram data: x is variable, y is the count/frequency
% order and variables in x and y should match
% order and variable labels in lbd should also match
% labels must be exact text for filter called variables
% any 16 variables or more I guess could go in this plot
x = [...
histy.Estar(2,:)',... %row 1 of plots
histy.Fit1R2(2,:)',...
histy.ModLength(2,:)',...
histy.Fit2R2(2,:)',...
histy.Fit1AAR(2,:)',... % row 2 of plots
histy.Fit1MAR(2,:)',...
histy.Fit2AAR(2,:)',...
histy.Fit2MAR(2,:)',...
histy.hchange(2,:)',... % row 3 of plots
histy.Fit3R2(2,:)',...
histy.Fit4AAR(2,:)',...
histy.Fit4MAR(2,:)',...
histy.P_star(2,:)',... % row 4 of plots
histy.h_star(2,:)',...
histy.dP(2,:)',...
histy.dH(2,:)',...
];
xlb = {'Modulus';...
'R21';...
'ModLength';...
'R22';...
'AAR1';...
'MAR1';...
'AAR2';...
'MAR2';...
'h_change';...
'R23';...
'AAR4';...
'MAR4';...
'P*';...
'h*';...
'dP';...
'dH'};
y = [...
histy.Estar(1,:)',...
histy.Fit1R2(1,:)',...
histy.ModLength(1,:)',...
histy.Fit2R2(1,:)',...
histy.Fit1AAR(1,:)',...
histy.Fit1MAR(1,:)',...
histy.Fit2AAR(1,:)',...
histy.Fit2MAR(1,:)',...
histy.hchange(1,:)',...
histy.Fit3R2(1,:)',...
histy.Fit4AAR(1,:)',...
histy.Fit4MAR(1,:)',...
histy.P_star(1,:)',...
histy.h_star(1,:)',...
histy.dP(1,:)',...
histy.dH(1,:)',...
];
for ii = 1:16 % number of plots
h(ii) = subplot(4,4,ii);
plot(x(:,ii),y(:,ii),'b.-');
axis([min(x(:,ii)), max(x(:,ii)), min(y(:,ii)), max(y(:,ii))])
xlabel(xlb{ii});
offset = -0.01;
wd = 0.01;
% left slider, low
hslide(ii) = uicontrol('style','slider');
set(hslide(ii),'units',get(h(ii),'units'))
subpos = get(h(ii),'position');
% position left, bot, width, height
slidepos = [subpos(1)+2.8*offset subpos(2)+offset wd subpos(4)-2*offset];
set(hslide(ii),'position',slidepos);
set(hslide(ii),'Callback',@SliderCallback);
set(hslide(ii),'Min',min(x(:,ii)),'Max',max(x(:,ii)),'Value',min(x(:,ii)));
% right slider, high
hslide(ii+16) = uicontrol('style','slider');
set(hslide(ii+16),'units',get(h(ii),'units'))
subpos = get(h(ii),'position');
% position left, bot, width, height
slidepos = [subpos(1)+subpos(3)-offset-wd subpos(2)+offset wd subpos(4)-2*offset];
set(hslide(ii+16),'position',slidepos);
set(hslide(ii+16),'Callback',@SliderCallback);
set(hslide(ii+16),'Min',min(x(:,ii)),'Max',max(x(:,ii)),'Value',max(x(:,ii)));
end
function SliderCallback(~,~)
for ii = 1:16
% update plots
SliderValue_L = get(hslide(ii),'Value');
SliderValue_R = get(hslide(ii+16),'Value');
new_data = ( x(:,ii) >= SliderValue_L & x(:,ii) <= SliderValue_R );
newy_data = y(new_data,ii);
newx_data = x(new_data,ii);
subplot(4,4,ii)
plot(newx_data, newy_data,'b.-');
axis([min(x(:,ii)), max(x(:,ii)), min(y(:,ii)), max(y(:,ii))])
xlabel(xlb{ii});
end
end
uicontrol('style','pushbutton','String',...
'Save New Filter',...
'Position', [20 40 160 30],...
'Callback',@UpdateFilter);
function UpdateFilter(~,~)
for ii = 1:16
bw = abs(x(1,ii)-x(2,ii)); % histogram bin width
tol = 0.05*bw; % tolerance
newslider(ii) = get(hslide(ii),'Value') - (bw/2 + tol);
newslider(ii+16) = get(hslide(ii+16),'Value') + (bw/2 + tol);
end
filt_n = [newslider(1:16); newslider(17:32)];
filt = [xlb, num2cell(filt_n,1)'];
assignin('base', 'NewFilt', filt);
end
end