一、部分代碼
close all clear clc rng('default'); %% 載入數據 data.S=[50,950,12]; %起點位置 橫坐標與縱坐標需為50的倍數 data.E=[950,50,1]; %終點點位置 橫坐標與縱坐標需為50的倍數 data.Obstacle=xlsread('data1.xls'); data.numObstacles=length(data.Obstacle(:,1)); %% 畫圖 figure hold on plot(curve,'r','LineWidth',2) xlabel('迭代次數') ylabel('路徑長度') legend(str); [~,result]=fobj(Best_pos); drawPc(result,option,data,str) result.path(:,1)=result.path(:,1).*data.unit(1); result.path(:,2)=result.path(:,2).*data.unit(2); result.path(:,3)=result.path(:,3).*data.unit(3); %% 顯示路徑信息 fprintf("路徑坐標:\n"); display(result.path) fprintf("路徑長度:%f\n",result.fit);
二、部分結果
路徑坐標:
??50??950??12
??100??900??11
??100??850??11
??100??800??10
??150??750???9
??200??700???8
??250??650???7
??250??600???7
??250??550???7
??250??500???7
??250??450???7
??300??400???6
??350??400???6
??400??350???5
??450??350???5
??500??350???5
??550??300???5
??600??300???5
??650??300???5
??700??250???4
??750??200???4
??800??150???3
??850??100???2
??900??100???2
??950??50???1
路徑長度:1448.608844
三、完整MATLAB代碼
基于北方蒼鷹優化算法NGO的復雜城市地形下無人機避障三維航跡規劃,可以修改障礙物及起始點(Matlab代碼)-CSDN博客
基于鵜鶘優化算法POA的復雜城市地形下無人機避障三維航跡規劃,可以修改障礙物及起始點(Matlab代碼)-CSDN博客
基于蛇優化算法SO的復雜城市地形下無人機避障三維航跡規劃,可以修改障礙物及起始點(Matlab代碼)-CSDN博客