MATLAB Answers

0

How to find the lowest value of Dist?

Asked by vinicius lanziotti on 7 Dec 2017
Latest activity Commented on by Image Analyst
on 18 Dec 2017
x=[1 2 3 4 5];
d= [0 10 20 30 40;
10 0 50 60 70;
20 50 0 80 90;
30 60 80 0 100;
40 70 90 100 0];
n=2;
for k=1:n
xp = randperm(numel(x), 2);
x(xp) = x(fliplr(xp))
s = sub2ind(size(d),x(1:end-1),x(2:end ));
Dist = sum(d(s))
end
for k=1:n
xp = randperm(numel(x), 4);
x(xp) = x(fliplr(xp))
s = sub2ind(size(d),x(1:end-1),x(2:end ));
Dist = sum(d(s))
end
lowest_Dist = ?

  0 Comments

Sign in to comment.

Tags

1 Answer

Answer by Image Analyst
on 7 Dec 2017
Edited by Image Analyst
on 7 Dec 2017

Index Dist:
Dist(k) = sum(d(s))
Then, perhaps:
lowest_Dist = min(Dist)
If not, why not?

  1 Comment

Did this work for you, or not??

Sign in to comment.