📄 matlab画图文件.m
字号:
%TSP问题的统计与画图
iterfile = fopen( 'c:\SA_Iters_File_eil51_9.txt', 'rt' );
cityfile = fopen( 'c:\SA_Citys_File_eil51_9.txt', 'rt' );
if( iterfile == -1 || cityfile == -1 )
display( 'File not exist!!' );
exit;
end
iters = fscanf( iterfile, '%d %f %f',[ 3,inf] );
citys = fscanf( cityfile, '%f %f',[ 2,inf] );
fclose( iterfile );
fclose( cityfile );
subplot(1,2,1);
plot( iters(2,:), iters(3,:) ), xlabel('迭代时间s'), ylabel('最短路径路程'), title('路径优化过程');
subplot(1,2,2);
plot( citys(1,:), citys(2,:),'-b' ), xlabel('X坐标'), ylabel('Y坐标'), title('求解路径');
hold on;
plot( citys(1,1), citys(2,1), 'r*', 'MarkerSize', 12 );
for i = 2:length(citys)
if( mod( i, 2 ) == 1 )
plot( citys(1,i), citys(2,i), 'r*', 'MarkerSize', 4 );
else
plot( citys(1,i), citys(2,i), 'bs', 'MarkerSize', 4 );
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -