1 function drawRoute (route, coordsMatrix)
3 % description: draws a given TSP route on the figure.
4 % author: Laurens Van Houtven <lvh@laurensvh.be>
7 % Find the length of the route.
8 routeDims = size(route);
9 routeLen = routeDims(2);
11 % Extract coordinate vectors for easy access.
12 xSourceCoords = coordsMatrix(:,2);
13 ySourceCoords = coordsMatrix(:,3);
15 % Initialize drawing vectors for speed.
16 xDrawCoords = zeros(routeLen);
17 yDrawCoords = zeros(routeLen);
21 thisVertex = route(i);
23 % Add the coordinates of this vertex to the draw vector.
24 xDrawCoords(i) = xSourceCoords(thisVertex);
25 yDrawCoords(i) = ySourceCoords(thisVertex);
28 % Plot the two drawvectors with a yellow line between them.
29 plot(xDrawCoords, yDrawCoords, 'Color', 'blue');
31 % Draw it on the current frame.