📄 plotcities.m
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -