关于模拟退火算法和遗传算法,粒子群算法。

11 views (last 30 days)
N/A
N/A on 16 Nov 2022
本人在做设计,但是对matlab是一个菜鸟,有没有人能帮忙在线讲解的?有的话麻烦添加本人的QQ569236335或者留个联系方式这个是画出路径的,但是运行的时候matlab总是提示未定义Chrom,能问一下是什么原因?怎么改?
function DrawPath(Chrom,X)%Chrom-待画路线;X-各城市坐标位置
R=[Chrom(1,:) Chrom(1,1)]; %一个随机解
figure;
hold on
plot(X(:,1),X(:,2),'o','color',[0.5,0.5,0.5])
plot(X(Chrom(1,1),1),X(Chrom(1,1),2),'rv','MarkerSize',20)
for i=1:size(X,1)
text(X(i,1)+0.05,X(i,2)+0.05,num2str(i),'color',[1,0,0]);
end
A=X(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
end

Answers (0)

Categories

Find more on MATLAB 快速入门 in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!