% Interactively plot a rectangle within an axes
% f = figure;
% a = axes('Parent',f);
% disableDefaultInteractivity(a)
% k = waitforbuttonpress;
% point1 = a.CurrentPoint; % button down detected
% finalRect = rbbox; % return figure units
% point2 = a.CurrentPoint; % button up detected
% point1 = point1(1,1:2); % extract x and y
% point2 = point2(1,1:2);
% enableDefaultInteractivity(a)
% p1 = min(point1,point2); % calculate locations
% offset = abs(point1-point2); % and dimensions
% x = [p1(1) p1(1)+offset(1) p1(1)+offset(1) p1(1) p1(1)];
% y = [p1(2) p1(2) p1(2)+offset(2) p1(2)+offset(2) p1(2)];
% hold on
% axis manual
% plot(x,y) % redraw in dataspace units
%