MATLAB: How to join points within a plot with a line

lineplot

I have this plot that consistes of five vector points with one minimun and one maximum each one. I want to automatically draw a line to join all the maximum points, and all the minimum points horizontally.
I am proceding the following way,
clc,clear
b = datestr(datenum(now),1);
for k1 = 1:5
x(k1) = datenum(addtodate(datenum(b), k1, 'day'));
end
xs = datestr(x,1)
x;
y1 = max([5,10]);
y2 = max([5,10]);
y3 = max([12,17]);
y4 = max([12,16]);
y5 = max([12,17]);
y8 = min([5,10]);
y9 = min([5,10]);
y10 = min([12,17]);
y11 = min([12,16]);
y12 = min([12,17]);
plot(x(1),y1,'-- ys','LineWidth',2,'MarkerEdgeColor','r','MarkerFaceColor','g','MarkerSize',10)
hold on
plot(x(1),y8,'--ys','LineWidth',2,'MarkerEdgeColor','b','MarkerFaceColor','y','MarkerSize',10)
plot(x(2),y2,'-- ys','LineWidth',2,'MarkerEdgeColor','r','MarkerFaceColor','g','MarkerSize',10)
plot(x(2),y9,'--ys','LineWidth',2,'MarkerEdgeColor','b','MarkerFaceColor','y','MarkerSize',10)
plot(x(3),y3,'-- ys','LineWidth',2,'MarkerEdgeColor','r','MarkerFaceColor','g','MarkerSize',10)
plot(x(3),y10,'--ys','LineWidth',2,'MarkerEdgeColor','b','MarkerFaceColor','y','MarkerSize',10)
plot(x(4),y4,'-- ys','LineWidth',2,'MarkerEdgeColor','r','MarkerFaceColor','g','MarkerSize',10)
plot(x(4),y11,'--ys','LineWidth',2,'MarkerEdgeColor','b','MarkerFaceColor','y','MarkerSize',10)
plot(x(5),y5,'-- ys','LineWidth',2,'MarkerEdgeColor','r','MarkerFaceColor','g','MarkerSize',10)
plot(x(5),y12,'--ys','LineWidth',2,'MarkerEdgeColor','b','MarkerFaceColor','y','MarkerSize',10)
datetick('x',1,'keepticks');
title('Wind(Knots) versus Time (dd-mmmm-yyyy)','fontsize',12,'fontweight','b','fontname','times');
xlabel('Time (dd-mmmm-yyyy)','fontweight','b','fontname','times');
ylabel('Wind (Knots)','fontweight','b','fontname','times');
set(gca,'fontname','times')
grid minor
Once again, I want to draw a horizontal line from the first maximum including all the points all the way untill the last number, and the same for the minimum points.
Can you please help?

Best Answer

ymin=[y8 y9 y10 y11 y12 ];
ymax=[y1 y2 y3 y4 y5];
plot(x,ymin,'--ys','LineWidth',2,'MarkerEdgeColor','r',...
'MarkerFaceColor','g','MarkerSize',10)
hold on
plot(x,ymax,'--ys','LineWidth',2,'MarkerEdgeColor','r',...
'MarkerFaceColor','g','MarkerSize',10)