plotcities.m
来自「Traveling Salesman Problem (TSP) has bee」· M 代码 · 共 29 行
M
29 行
function f = plotcities(inputcities)
% PLOTCITIES
% PLOTCITIES(inputcities) plots the location of cities from the argument
% inputcities. Inputcities argument has 2 rows and n columns, where n is
% the number of cities. Apart from the location the symmetric route is also
% plotted.
shg
temp_1 = plot(inputcities(1,:),inputcities(2,:),’b*’);
set(temp_1,’erasemode’,’none’);
temp_2 = line(inputcities(1,:),inputcities(2,:),’Marker’,’*’);
set(temp_2,’color’,’r’);
x = [inputcities(1,1) inputcities(1,length(inputcities))];
y = [inputcities(2,1) inputcities(2,length(inputcities))];
x1 = 10*round(max(inputcities(1,:))/10);
y1 = 10*round(max(inputcities(2,:))/10);
if x1 == 0
x1 = 1;
end if y1 == 0
y1 = 1;
end
axis([0 x1 0 y1]);
temp_3 = line(x,y);
set(temp_3,’color’,’r’);
dist = distance(inputcities);
distance_print = sprintf(...
’The roundtrip length for %d cities is % 4.6f units’...
,length(inputcities),dist);
text(x1/15,1.05*y1,distance_print,’fontweight’,’bold’);
drawnow;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?