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

1 view (last 30 days)
maatoug ayoub on 19 Apr 2018
Commented: maatoug ayoub on 19 Apr 2018
dmat = reshape(sqrt(sum((xy(a,:)-xy(a',:)).^2,2)),N,N);


njj1 on 19 Apr 2018
So what is your variable 'a'? What is the size of 'xy'?
maatoug ayoub on 19 Apr 2018
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
maatoug ayoub on 19 Apr 2018
this is a part of the script

njj1 on 19 Apr 2018
Edited: njj1 on 19 Apr 2018
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)

Show 1 older comment
maatoug ayoub on 19 Apr 2018
thank you very much ..so sum((xy(a,:)-xy(a',:) its equal {(x_i - x_j)
njj1 on 19 Apr 2018
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.
maatoug ayoub on 19 Apr 2018
thank you my friend now i untrestand it