www.pudn.com > TWVRP.rar > DrawPath.m, change:2016-04-20,size:831b


function DrawPath(minbestpop1,xy) 
%% 画路径函数 
%输入 
% minbestpop1  待画路径    
% xy      各城市坐标位置 
r=[minbestpop1,minbestpop1(1)]; %最优解(个体) 
  
nx=size(r,2); 
figure; 
hold on; 
plot(xy(:,1),xy(:,2),'o','color',[0,0,0]); 
plot(xy(r(1),1),xy(r(1),2),'rv','MarkerSize',20) 
for i=1:size(xy,1) 
    text(xy(i,1)+0.2,xy(i,2)+0.2,num2str(i),'color',[0,0,1]); 
    %set(gca,'Fontsize',15) 
end 
for i=1:nx-1 
      xx=[xy(r(i),1),xy(r(i+1),1)]; 
      yy=[xy(r(i),2),xy(r(i+1),2)]; 
      plot(xx,yy,'-','color',[0,0,0]); 
      hold on; 
 end 
box on; 
%A=xy(R,:); 
%row=size(A,1); 
%for i=2:row 
    %[arrowx,arrowy] = dsxy2figxy(gca,A(i-1:i,1),A(i-1:i,2));%坐标转换 
    %annotation('textarrow',arrowx,arrowy,'HeadWidth',8,'color',[0,0,1]); 
%end 
hold off 
xlabel('横坐标') 
ylabel('纵坐标') 
title('轨迹图') 
box on