MATLAB: Logic issues for creating a random walk

lineplotpointsrandomwalk

I have a set of random points plotted. I want to create a random walk between all of these plotted points so they are all visited once and only once. Then i will want to repeat many more random walks to find the best solution.
I am struggling with the logic needed to plot lines between my points and make sure they are only visited once. So any help with that would be appreciated, the rest i can work out.

Best Answer

Hi.
plot([x1 x2],[y1,y2])
For all lines:
xCor = rand(1,10)
yCor = rand(1,10)
Cor = [xCor; yCor]
subplot(1,1,1);
plot(xCor,yCor,'r.','MarkerSize',20)
c = randperm(10,10)
x1 = Cor(1,c(1:9))
y1 = Cor(2,c(1:9))
x2 = Cor(1,c(2:10))
y2 = Cor(2,c(2:10))
hold on;
plot([x1;x2],[y1;y2])