forked from esokos/isola
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotrakeuncert.m
169 lines (144 loc) · 4.72 KB
/
plotrakeuncert.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
function plotrakeuncert(elipsa_max,rake1,rake2)
f=figure;
%subplot(2,2,1)
hist(elipsa_max(:,7),36);
n=hist(elipsa_max(:,7),36);
hold on
x=[rake1 rake1];
y=[0 max(n)];
line(x,y,'Color','r','LineWidth',4,'ButtonDownFcn', @startDragFcn1);
h1strike=line(x,y,'Color','r','LineWidth',3,'LineStyle','--','ButtonDownFcn', @startDragFcn1);
set(h1strike,'UserData', 0)
h1text=text(rake1+5,max(n),'\pm0\circ','FontSize',12);
x=[rake2 rake2];
y=[0 max(n)];
line(x,y,'Color','r','LineWidth',4,'ButtonDownFcn', @startDragFcn2);
h2strike=line(x,y,'Color','r','LineWidth',4,'LineStyle','--','ButtonDownFcn', @startDragFcn2);
set(h2strike,'UserData', 0)
h2text=text(rake2+5,max(n),'\pm0\circ','FontSize',12);
title('Rake')
h=axis;
axis([-180 180 h(3) h(4)])
aH=get(gcf,'CurrentAxes'); %('Xlim', [0 1], 'Ylim',[0 1]);
set(f,'WindowButtonUpFcn',{@stopDragFcn,rake1,rake2,max(n)});
function startDragFcn1(varargin)
set(f,'WindowButtonMotionFcn', @draggingFcn1)
set(h1strike,'Color','y')
set(h1strike,'UserData',1)
end
function draggingFcn1(varargin)
pt=get(aH,'CurrentPoint');
set(h1strike,'XData', pt(1)*[1 1])
end
function startDragFcn2(varargin)
set(f,'WindowButtonMotionFcn', @draggingFcn2)
set(h2strike,'Color','g')
set(h2strike,'UserData',1)
end
function draggingFcn2(varargin)
pt=get(aH,'CurrentPoint');
set(h2strike,'XData', pt(1)*[1 1])
end
function stopDragFcn(varargin)
set(f,'WindowButtonMotionFcn','');
rake1=varargin{3};
rake2=varargin{4};
llimit1=get(h1strike,'XData');
llimit2=get(h2strike,'XData');
ud1=get(h1strike,'UserData');
ud2=get(h2strike,'UserData');
s1=abs(llimit1(1)-varargin{3});
s2=abs(llimit2(1)-varargin{4});
% find what user clicked
if ud1==0 && ud2==1
% disp('worked with 2')
% calculate the right limit for rake2
if rake1 < rake2
rlimit2=rake2-s2;
else
rlimit2=rake2+s2;
end
% plot another line
x=[rlimit2 rlimit2];
y=[0 varargin{5}];
line(x,y,'Color','g','LineWidth',3,'LineStyle','--');
set(h2text,'String', [num2str(fix(rake2)) ' ' '\pm' num2str(s2,'%3.0f') '\circ'])
set(h2strike,'UserData',0)
elseif ud1==1 && ud2==0
% disp('worked with 1')
rlimit1=rake1+(rake1-llimit1(1));
% calculate the right limit for rake1
if rake1 < rake2
rlimit2=rake1+s2;
else
rlimit2=rake1-s2;
end
% plot another line
x=[rlimit1 rlimit1];
y=[0 varargin{5}];
line(x,y,'Color','y','LineWidth',3,'LineStyle','--');
set(h1text,'String', [num2str(fix(rake1)) ' ' '\pm' num2str(abs(s1),'%3.0f') '\circ'])
set(h1strike,'UserData',0)
end
% % if llimit1 < rake1
% % elseif llimit1 > rake1
% % s1=llimit1(1)-varargin{3};
% %
% % end
%
% ud1=get(h1strike,'UserData');
% ud2=get(h2strike,'UserData');
%
% if ud1 ==0 && ud2==0 % no calculations yet
% % find left limit
% if s1~=0
% % calculate the right limit for rake1
% rlimit1=rake1+(rake1-llimit1(1));
% % plot another line
% x=[rlimit1 rlimit1];
% y=[0 varargin{5}];
% line(x,y,'Color','y','LineWidth',3,'LineStyle','--');
% set(h1strike,'UserData',1)
% set(h2strike,'UserData',0)
% set(h1text,'String', ['\pm' num2str(abs(s1),'%3.0f') '\circ'])
%
% elseif s2 ~=0
% % find left limit
% % llimit1=get(h2strike,'XData');
% % calculate the right limit for rake1
% rlimit2=rake2-(llimit2(1)-rake2);
% % plot another line
% x=[rlimit2 rlimit2];
% y=[0 varargin{5}];
% line(x,y,'Color','g','LineWidth',3,'LineStyle','--');
% set(h2strike,'UserData',1)
% set(h1strike,'UserData',0)
% set(h2text,'String', ['\pm' num2str(s2,'%3.0f') '\circ'])
% else
% disp('try again')
% end
%
% elseif ud1==0 && ud2==1 %strk2 was set
% % calculate the right limit for rake1
% rlimit1=rake1+(rake1-llimit1(1));
% % plot another line
% x=[rlimit1 rlimit1];
% y=[0 varargin{5}];
% line(x,y,'Color','y','LineWidth',3,'LineStyle','--');
% set(h1strike,'UserData',1)
% set(h1text,'String', ['\pm' num2str(abs(s1),'%3.0f') '\circ'])
%
% elseif ud1==1 && ud2==0
% % find left limit
% % llimit1=get(h2strike,'XData');
% % calculate the right limit for rake1
% rlimit2=rake2-(llimit2(1)-rake2);
% % plot another line
% x=[rlimit2 rlimit2];
% y=[0 varargin{5}];
% line(x,y,'Color','g','LineWidth',3,'LineStyle','--');
% set(h2strike,'UserData',1)
% set(h2text,'String', ['\pm' num2str(s2,'%3.0f') '\circ'])
% end
end % end of stopDragFcn
end % end of main