clear;
clc;
close all ;
figure;
xmax = 5 ;
xmin = 0 ;
ymax = 0.5 ;
x=[xmin,xmax];
y=[0,0] ;
plot(x,y), hold on ;
xlabel('\itkm \color{blue}\itWater '); ylabel('\itkm '); ...
title(' \color[rgb]{.5 .5 .2}\it Land');
axis([xmin, xmax, -ymax, ymax]);
x = rand(2,1);
y = ymax * rand(2,1) ;
LifeGuardx = x(1) ;
LifeGuardy = y(1) ;
Swimmerx = xmax-x(2) ;
Swimmery = -y(2) ;
plot(LifeGuardx,LifeGuardy,'x',Swimmerx,Swimmery,'o'), hold on ;
fprintf('\nClick two points on horizontal line in figure.\n');
[ShorexPt1,ShoreyPt1,button] = ginput(1);
plot(ShorexPt1,ShoreyPt1,'ro')
DistkmShorePt1 = sqrt((ShorexPt1 - LifeGuardx)^2 + (ShoreyPt1 - LifeGuardy)^2), disp('km')
DistmilesShorePt1 = (DistkmShorePt1 * 0.6241), disp('mi');
DistkmSwimmerPt1 = sqrt((ShorexPt1 - Swimmerx)^2 + (ShoreyPt1 - Swimmery)^2), disp('km');
DistmilesSwimmerPt1 = (DistkmSwimmerPt1 * 0.6241), disp('mi');
TimePt1 = (DistmilesShorePt1 * 7), disp('min')
TimePt2 = (DistmilesSwimmerPt1 * 60), disp('min')
TotalTime1 = TimePt1 + TimePt2
[ShorexPt2,ShoreyPt2,button] = ginput(1);
plot(ShorexPt2,ShoreyPt2,'go')
DistkmShorePt2 = sqrt((ShorexPt2 - LifeGuardx)^2 + (ShoreyPt2 - LifeGuardy)^2), disp('km')
DistmilesShorePt2 = (DistkmShorePt2 * 0.6241), disp('mi');
DistkmSwimmerPt2 = sqrt((ShorexPt2 - Swimmerx)^2 + (ShoreyPt2 - Swimmery)^2), disp('km');
DistmilesSwimmerPt2 = (DistkmSwimmerPt2 * 0.6241), disp('mi');
TimePt3 = (DistmilesShorePt2 * 7), disp('min')
TimePt4 = (DistmilesSwimmerPt2 * 60), disp('min')
TotalTime2 = TimePt3 + TimePt4
[ShorexPt3,ShoreyPt3,button] = ginput(1);
plot(ShorexPt3,ShoreyPt3,'bo')
DistkmShorePt3 = sqrt((ShorexPt3 - LifeGuardx)^2 + (ShoreyPt3 - LifeGuardy)^2), disp('km')
DistmilesShorePt3 = (DistkmShorePt3 * 0.6241), disp('mi');
DistkmSwimmerPt3 = sqrt((ShorexPt3 - Swimmerx)^2 + (ShoreyPt3 - Swimmery)^2), disp('km');
DistmilesSwimmerPt3 = (DistkmSwimmerPt2 * 0.6241), disp('mi');
TimePt5 = (DistmilesShorePt3 * 7), disp('min')
TimePt6 = (DistmilesSwimmerPt3 * 60), disp('min')
TotalTime3 = TimePt5 + TimePt6
if TimePt1 < TimePt2
plot([LifeGuardx, ShorexPt1], [LifeGuardy,ShoreyPt1]);
plot([Swimmerx, ShorexPt1], [Swimmery,ShoreyPt1]);
end