I am not entirely sure that I understand your problem. You want to have line between the last and the first point, correct? Then you simply might consider changing the plot command to plot([xs,xs(1)],[ys,ys(1)],'r-');
If you have column vetors, this will not work, but the following code will: plot([xs;xs(1)],[ys;ys(1)],'r-');
I hope this solves your problem.