% Draw a "button" at a randomly generated location and evaluate whether a
% user clicks on the button

close all % Close all previous figure windows
figure % Start a new figure window
hold on % Keep the same set of axes (multiple plots on same axes)
axis equal % unit lengths on x- and y-axis are equal

% Size of plot area
plotWidth = 9;
plotHeight = 9;
axis([0 plotWidth 0 plotHeight]) % x-axis limits [0,9], y-axis limits [0,9]

% Size of the button to be drawn
btnWidth= 2; % Width of button
btnHeight= 0.5; % Height of button

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Do not change the code above %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Modify the code below %%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Demo (you probably want to move or delete this code)
plot([1 5], [3 3], 'r-') % Plot horizontal red line
plot([1 5], [4 4], 'b-') % Plot horizontal blue line
title('Click below in the graph area')
[xp, yp]= ginput(1); % (xp,yp) are the x- and y-coordinates of the user's
% mouse click.
messageToPrint= sprintf('You made a mouse click at (%.1f,%.1f)', xp, yp);
title(messageToPrint)

% Draw a "button" at a randomly generated position.
% The entire button must be in the axes area and the text 'Click here' is
% approximately centered on the button.

% Accept a user click and plot its location

% Evaluate whether user clicked on the button and display an appropriate
% message

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Do not change the code below %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
hold off % Next plot command refreshes (clears) the axes