用matelab求解送货点之间最短路径问题

具体看图

getallDis.m文件(工具类程序文件)
表现:function s = getallDis()
主要功能:求出各个送货点的距离举证,并存入dis.txt
源代码:
function s = getallDis()
%UNTITLED1 Summary of this function goes here
% Detailed explanation goes here
% author:manager
x=xlsread('point.xls','b3:b33');
y=xlsread('point.xls','c3:c33');

for i=1:31
for j=1:31
a(i,j)=abs(x(i)-x(j))+abs(y(i)-y(j));
end
end

file=fopen('dis.txt','w');
for i=1:31
for j=1:31
% fprintf(file,',');
fprintf(file,',%d',a(i,j));
if mod(j,31)==0
fprintf(file,'\n');
end
end
end
fclose(file);

这个程序可能有错误,求改正
错误显示索引超出范围了,我猜应该是x的赋值成了一列数,导没有x2了

顺便问一下怎么转成这个表格

img

看看这个
https://b23.tv/lYrIVqS