Line | |
---|
1 | function [P1,P2] = clicksegment |
---|
2 | % CLICKSEGMENT Select a segment by clicking |
---|
3 | % [P1,P2] = CLICKSEGMENT lets the user select a segment in the |
---|
4 | % current figure and returns the starting and ending point P1 and P2. |
---|
5 | % |
---|
6 | % The user can abort the operation by pressing any key. In this |
---|
7 | % case the function returns the empty matrix. |
---|
8 | % |
---|
9 | % See also CLICK, CLICKPOINT. |
---|
10 | |
---|
11 | |
---|
12 | % Click first segment |
---|
13 | P1=click ; |
---|
14 | if isempty(P1) |
---|
15 | P2=P1 ; |
---|
16 | return ; |
---|
17 | end |
---|
18 | |
---|
19 | was_hold = ishold(gca) ; |
---|
20 | hold on ; |
---|
21 | h=plot(P1(1),P1(2),'rx') ; |
---|
22 | |
---|
23 | % Click second segment |
---|
24 | P2=click ; |
---|
25 | if isempty(P2) |
---|
26 | P1=P2 ; |
---|
27 | end |
---|
28 | delete(h) ; |
---|
29 | if ~was_hold, hold off ; end |
---|
30 | |
---|
Note: See
TracBrowser
for help on using the repository browser.