Environmental Engineering Reference
In-Depth Information
the text string
h0
, which is used in the sequel for other purposes. The following
commands (until the next
delete
) repeat the previous commands for reference
point 2. As these correspond exactly to the commands, outlined for reference point
1, they need not to be commented again.
In the final four lines the new coordinate system is computed and displayed on
the figure axes. The user may check that the linear transformation of coordinates,
gathered in the first two lines, is correct. The final command adds the real world
coordinates under
XLim
and
Ylim
axes properties. The specification of the
'Color'
property as
'none'
ensures that the image remains visible.
17.4 Digitizing
In the example it is shown how some characteristic structures, which are visualized
on the map, can be made known to MATLAB
in real-world coordinates. That is
done once for a line (structure) and once for locations. The command sequence
within the M-file is basically the same for both tasks.
®
% --------------------------- Set Line ----------------------------
h = gca; hold on;
h0 = text (xmin,ymin-0.05*(ymax-ymin),'Set line: left mouse button:…
set; right: last value','BackgroundColor','y',…
'EdgeColor','red','LineWidth',2);
but = 1; count = 0;
while
but == 1
[xi,yi,but] = ginput(1);
plot (xi,yi,'rx');
count = count+1;
xline(count) = xi; yline(count) = yi;
end
line (xline,yline,'Color','r');
delete (h0);
In the second command, the information text for the user is displayed below the
bottom axis; the text is: 'Set line: left mouse button: set; right: last value'. The user
is asked to set the locations of the polyline by mouse clicks on the left button. The
last input is indicated by a click on the right button instead of the left.
The main part of the command sequence is given in the
while
loop. Before the
loop is entered, the button indicator
but
is set to 1, and the point counter
count
to 0.
Within the loop, the first command questions the location of the click, storing the
results in the variables
xi
and
yi
. Moreover, the
but
variable is renewed,
depending on the mouse button that was used by the modeller. The left mouse
button is represented by a 1 in variable
but
, the right button by a 3.
The next instruction in the loop puts a red cross at the location selected by the
user. The counter is increased by 1 and the last coordinates are put into vectors
xline
and
yline
, which represent the current polyline.