this is my equation using matlab , i can't get it manually.

1 次查看(过去 30 天)
dmat = reshape(sqrt(sum((xy(a,:)-xy(a',:)).^2,2)),N,N);
  5 个评论
maatoug ayoub
maatoug ayoub 2018-4-19
编辑:Stephen23 2018-4-19
for k = nargin:nargs-1
switch k
case 0
xy = 10*rand(20,2);
case 1
N = size(xy,1);
a = meshgrid(1:N);
dmat = reshape(sqrt(sum((xy(a,:)-xy(a',:)).^2,2)),N,N);
case 2
salesmen = 4;
case 3
min_tour = 2;
case 4
pop_size = 80;
case 5
num_iter = 5e3;
case 6
show_prog = 1;
case 7
show_res = 1;
otherwise
end

请先登录,再进行评论。

采纳的回答

njj1
njj1 2018-4-19
编辑:njj1 2018-4-19
This looks like it's the distance from each (x,y) pair to every other (x,y) pair.
A_{i,j} = \sqrt{(x_i - x_j)^2}, where x = (x,y)
  4 个评论
njj1
njj1 2018-4-19
Yes, it is, but they do it in a clever, vectorized way, where they do not have any for loops to cycle through each i,j.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Functions 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by