Question: Write a matlab code that does the following coordinates [2,1; 3,1;4,5;2,3; 4,3] (this is just an example and the code must be able to handle

Write a matlab code that does the following coordinates [2,1; 3,1;4,5;2,3; 4,3] (this is just an example and the code must be able to handle all such distances)The code should be a function that takes the cityLocations as input and calculates the the tour with the nearest neighbor tour created by chosing random start node and moves to the nearest neighbour of univsited nodes. This distance should be the euclidean distance. It should not calculate the distance to itself so no zeros should be generated while calculatating any distances. After the end of a tour it should be returned to the starting city so also this distance should be caculated. So it is the total distance for this tour that should be returned by the function.

Step by Step Solution

3.31 Rating (163 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Coded for ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!