路径规划基于蚁群算法栅格地图路径规划matlab
Posted 博主QQ2449341593
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了路径规划基于蚁群算法栅格地图路径规划matlab相关的知识,希望对你有一定的参考价值。
路径规划是实现移动机器人自主导航的关键技术,是指在有障碍物的环境中,按照一定的评价标准(如距离、时间、能耗等),寻找到一条从起始点到目标点的无碰撞路径,这里选取最短距离路径规划的评价标准,即最短路径规划问题。
1.路径规划数学模型的建立
将移动机器人周围环境用一组数据进行抽象表达,建立二维或三维的环境模型,得到移动机器人能够理解分析的环境数据,是机器人路径规划的基本前提。我这里用的是栅格法,其原理是将周围环境看成一个二维平面,将平面分成一个个等面积大小的具有二值信息的栅格,每个栅格中存储着周围环境信息量,下图我给出了一个栅格法地图,方便大家更好的理解栅格地图。这里设计的栅格地图为一个20×20的地形矩阵,黑色的地方表示有障碍,白色的地方表示没有障碍。
图1 栅格法地图
在用栅格法建立环境模型时,为了将环境信息转换成移动机器人可以识别的数据,一般采用序号法标记环境地图信息,即将栅格地图中一个个栅格从序号1依次累加直到标记到最后一个栅格。如图2所示。
图2 序号法示意图
另外,对于一幅带有坐标的栅格图来说,每个栅格点有唯一的坐标,假设栅格规模为x行y列,第i个栅格对应的位置由式(1)所示。
式中a为每个小方格像素的边长,ceil(n)取大于等于数值n的最小整数,mod(i,y)求i除以y的余数。
每条路径(从起点走到终点)的长度可以由式(2)计算得出。
在解决环境建模之后,我们需要设计机器人移动的方法,这里我采用如图3所示的八叉树搜索策略,即机器人在搜索过程中可以朝附近八个方向的相邻栅格之间的自由移动。
图3 八叉树搜索策略
那么,怎么判断一个栅格点是否为另一个栅格点的相邻栅格点呢,另外,又怎么判断是否为有障碍栅格呢。这就需建立矩阵D,记录每个栅格点至其相邻栅格点的代价值。本例中栅格地图有20×20个栅格点,则D的大小为400×400,其中列是起点栅格,行是局部终点栅格,各栅格点至其各相邻无障碍栅格点的代价值非零,而有障碍栅格及非相邻栅格设为0。
这里需要说明的是,我的MATLAB程序来自于:
版权声明:本文为CSDN博主「qq_40443076」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_40443076/article/details/88179836
这里主要介绍基于蚁群算法的机器人最短路径规划的思路,以及我在运行MALTLAB程序的时候,学到的内容。
2.机器人最短路径规划的实现步骤
为了方便大家更好地理解蚁群算法的原理及实现过程,其流程图如图4所示。(流程图较长,我截图了两段。)
图4 基于蚁群算法的机器人最小路径规划流程图
图中公式(3)(4)的具体表达在下边的具体步骤里。
**步骤1:**给出栅格地图的地形矩阵;初始化信息素矩阵 Tau(记录每个栅格至其他栅格的信息素量),最大迭代次数K,蚂蚁个数M,表征信息素重要程度的参数 、表征启发式信息重要程度的参数 ,信息素蒸发系数 ,信息素增加强度系数Q及启发式信息矩阵
**步骤2:**构建启发式信息矩阵。按式(1)和式(2)计算每个栅格至目标点的距离,启发式信息素取为至目标点距离的倒数,距离越短,启发式因子越大,障碍物处的启发式信息为0。建立矩阵D,用以存储每个栅格点至各自相邻无障碍栅格点的代价值。
**步骤3:**对于每一只蚂蚁,初始化蚂蚁爬行的路径及路径长度,将禁忌列表全部初始化为1;蚂蚁从起始点出发开始搜索路径,找出当前栅格点的所有无障碍相邻栅格点(即矩阵D中相应元素不为0的栅格点),再根据禁忌列表筛选出当前可选择的栅格点。
**步骤4:**如果起始点是目标点,且可选栅格点个数大于等于1,则根据式(3)计算蚂蚁从当前栅格点转移到各相邻栅格点的概率,
并根据轮盘赌的方法选择下一个栅格点。
**步骤5:**更新蚂蚁爬行的路径、路径长度、矩阵D及禁忌列表。
**步骤6:**重复步骤4和5直到起始点为目标点或可选栅格点小于1,本次迭代中当前蚂蚁寻路完毕,记录该蚂蚁的行走路线。
**步骤7:**如果该蚂蚁最后一步是目标点,则计算路径长度并与当前已知的最短路径长度作比较,若本次路径长度小于当前已知的最短路径长度,则更新当前最短路径长度及最短路径;如果该蚂蚁最后一步不是目标的,则只将路径长度记为0。
**步骤8:**重复步骤3至步骤7直到M只蚂蚁完成一轮路径搜索,按照式(4)更新信息素。
**步骤9:**判断是否满足终止条件K,是结束蚁群算法寻优并绘制最优规划路径,否则转到步骤3。
function varargout = main_GUI_xu(varargin)
% MAIN_GUI_XU MATLAB code for main_GUI_xu.fig
% MAIN_GUI_XU, by itself, creates a new MAIN_GUI_XU or raises the existing
% singleton*.
%
% H = MAIN_GUI_XU returns the handle to a new MAIN_GUI_XU or the handle to
% the existing singleton*.
%
% MAIN_GUI_XU('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in MAIN_GUI_XU.M with the given input arguments.
%
% MAIN_GUI_XU('Property','Value',...) creates a new MAIN_GUI_XU or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before main_GUI_xu_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to main_GUI_xu_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help main_GUI_xu
% Last Modified by GUIDE v2.5 22-Mar-2017 15:58:57
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @main_GUI_xu_OpeningFcn, ...
'gui_OutputFcn', @main_GUI_xu_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before main_GUI_xu is made visible.
function main_GUI_xu_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to main_GUI_xu (see VARARGIN)
% Choose default command line output for main_GUI_xu
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes main_GUI_xu wait for user response (see UIRESUME)
% uiwait(handles.figure1);
init_all(handles)
set(handles.edit38,'string','先选择实验目的,默认选择目的一,即运行一种算法');
% --- Outputs from this function are returned to the command line.
function varargout = main_GUI_xu_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on selection change in listbox1.
function listbox1_Callback(hObject, eventdata, handles)
% hObject handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns listbox1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from listbox1
% --- Executes during object creation, after setting all properties.
function listbox1_CreateFcn(hObject, eventdata, handles)
% hObject handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% 绘制栅格线和调用figure的屏幕回调函数
global barrier pushbutton1_userdata
pushbutton1_userdata = 1; % 控制设计障碍物按钮是否能够使用
set(handles.edit38,'string','障碍物设计完成后,请点击输出障碍物按钮,否则容易出错');
axes(handles.axes1)
cla reset
n_barrier = str2double(get(handles.edit1,'string'));
barrier = zeros(n_barrier,n_barrier);
axes(handles.axes1);
s.hf = get(handles.axes1,'parent');
% 绘制栅格边线
for i=0:1:n_barrier
plot([0,n_barrier],[i,i],'color','k');
hold on
axis([0,n_barrier,0,n_barrier])
for j=0:1:n_barrier
plot([i,i],[0,n_barrier],'color','k') ;
hold on
axis([0,n_barrier,0,n_barrier])
end
end
% 设置figure的WindowButtonDownFcn属性
set(s.hf,'WindowButtonDownFcn',@figure1_windowbuttondownfcn)
% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
global barrier_select start_select goal_select pushbutton1_userdata barrier start goal
barrier_value = get(handles.popupmenu1,'value');
cd('barrier')
if barrier_value==2
barrier_select = xlsread('e_barrier');
start_select = 20;
goal_select = 295;
pushbutton1_userdata = 0;
elseif barrier_value==3
barrier_select = xlsread('simple_e');
start_select = 20;
goal_select = 295;
pushbutton1_userdata = 0;
elseif barrier_value==4
barrier_select = xlsread('u_barrier');
start_select = 1;
goal_select = 400;
pushbutton1_userdata = 0;
elseif barrier_value==5
barrier_select = xlsread('light_u_barrier');
start_select = 1;
goal_select = 400;
pushbutton1_userdata = 0;
elseif barrier_value==6
barrier_select = xlsread('right_u_barrier');
start_select = 1;
goal_select = 400;
pushbutton1_userdata = 0;
elseif barrier_value==7
barrier_select = xlsread('z_barrier');
start_select = 49;
goal_select = 369;
pushbutton1_userdata = 0;
elseif barrier_value==8
barrier_select = xlsread('complex_z');
start_select = 47;
goal_select = 367;
pushbutton1_userdata = 0;
elseif barrier_value==9
barrier_select = xlsread('complex_1');
start_select = 1;
goal_select = 400;
pushbutton1_userdata = 0;
elseif barrier_value==10
barrier_select = xlsread('complex_2');
start_select = 1;
goal_select = 400;
pushbutton1_userdata = 0;
elseif barrier_value==11
barrier_select = xlsread('complex_30');
start_select = 1;
goal_select = 890;
pushbutton1_userdata = 0;
elseif barrier_value==12
barrier_select = xlsread('complex_50_1');
start_select = 1;
goal_select = 2500;
elseif barrier_value==13
barrier_select = xlsread('complex_50_2');
start_select = 1;
goal_select = 2500;
pushbutton1_userdata = 0;
elseif barrier_value==14
barrier_select = xlsread('complex_50_3');
start_select = 1;
goal_select = 2500;
pushbutton1_userdata = 0;
elseif barrier_value==15
barrier_select = xlsread('barrier_tmp');
set(handles.edit18,'string','请选择起点和终点')
pushbutton1_userdata = 0;
start = 0;
goal = 0;
end
cd ..
X = size(barrier_select,1);
Y = size(barrier_select,2);
axes(handles.axes1);
barrier = barrier_select;
figure_barrier(barrier,handles);
start = start_select;
goal = goal_select;
set(handles.edit2,'string',num2str(start) );
set(handles.edit3,'string',num2str(goal) );
% 画起点
x_goal_new = ( mod(start-1,X) +1-0.5);
y_goal_new = ( Y- ceil(start/Y) +1-0.5);
x_start_floor = floor(x_goal_new);
x_start_ceil = ceil(x_goal_new);
y_start_floor = floor(y_goal_new);
y_start_ceil = ceil(y_goal_new);
x_data = [x_start_floor,x_start_ceil,x_start_ceil,x_start_floor];
y_data = [y_start_floor,y_start_floor,y_start_ceil,y_start_ceil];
fill(x_data,y_data,[0,1,0]);
% 画终点
x_goal_new = ( mod(goal-1,X) +1-0.5);
y_goal_new = ( Y- ceil(goal/Y) +1-0.5);
x_start_floor = floor(x_goal_new);
x_start_ceil = ceil(x_goal_new);
y_start_floor = floor(y_goal_new);
y_start_ceil = ceil(y_goal_new);
x_data = [x_start_floor,x_start_ceil,x_start_ceil,x_start_floor];
y_data = [y_start_floor,y_start_floor,y_start_ceil,y_start_ceil];
fill(x_data,y_data,[1,0,0]);
% 设置通用参数
num_ant = 2*X;
set(handles.edit9,'string',num_ant);
set(handles.edit10,'string',250);
set(handles.edit18,'string',10)
set(handles.axes2,'visible','on')
% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in radiobutton1.
function radiobutton1_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton1
set(handles.uipanel200,'visible','off')
set(handles.uipanel201,'visible','off')
set(handles.uipanel202,'visible','on')
set(handles.uipanel203,'visible','off')
set(handles.uipanel204,'visible','off')
% --- Executes on button press in radiobutton2.
function radiobutton2_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton2
set(handles.uipanel200,'visible','off')
set(handles.uipanel201,'visible','on')
set(handles.uipanel202,'visible','off')
set(handles.uipanel203,'visible','off')
set(handles.uipanel204,'visible','off')
% --- Executes on button press in radiobutton3.
function radiobutton3_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton3
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit2_Callback(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit2 as text
% str2double(get(hObject,'String')) returns contents of edit2 as a double
% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit3_Callback(hObject, eventdata, handles)
% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit3 as text
% str2double(get(hObject,'String')) returns contents of edit3 as a double
% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% 鼠标取起点
global permission_start
permission_start = 1;
set(handles.edit2,'string',[]);
set(handles.edit3,'string',[]);
axes(handles.axes1);
if permission_start==1
set(handles.edit38,'string','选择起点结束后请点击结束按钮,否则易出错');
s.hf = get(handles.axes1,'parent');
set(s.hf,'WindowButtonDownFcn',@figure1_windowbuttondownfcn_point_start);
end
global start
figure_start(start)
function figure1_windowbuttondownfcn_point_start(hobj,event)
global barrier
X = size(barrier,1);
Y = size(barrier,2);
global permission_start
if permission_start==1
if strcmp(get(hobj,'SelectionType'),'normal')
p = get(gca,'currentpoint'); % 取鼠标当前所在点的坐标
x(1) = p(1);% 当前点的横坐标;
x_ceil = ceil(x(1));
y(1) = p(3);% 当前点的纵坐标
y_ceil = ceil(y(1));
point_start = [x_ceil,y_ceil];
start_tmp = point_start(1) + ( Y-point_start(2) )*X;
figure_start(start_tmp);
end
end
% 画出起点函数
function figure_start(start_new)
global barrier start
if start_new~=start
X = size(barrier,1);
Y = size(barrier,2);
% 清除以前的点的消息
x_start = ( mod(start-1,X) +1-0.5);
y_start = ( Y- ceil(start/Y) +1-0.5);
x_start_floor = floor(x_start);
x_start_ceil = ceil(x_start);
y_start_floor = floor(y_start);
y_start_ceil = ceil(y_start);
x_data = [x_start_floor,x_start_ceil,x_start_ceil,x_start_floor];
y_data = [y_start_floor,y_start_floor,y_start_ceil,y_start_ceil];
fill(x_data,y_data,[1,1,1]);
%% 画新的点
x_start_new = ( mod(start_new-1,X) +1-0.5);
y_start_new = ( Y- ceil(start_new/Y) +1-0.5);
x_start_floor = floor(x_start_new);
x_start_ceil = ceil(x_start_new);
y_start_floor = floor(y_start_new);
y_start_ceil = ceil(y_start_new);
x_data = [x_start_floor,x_start_ceil,x_start_ceil,x_start_floor];
y_data = [y_start_floor,y_start_floor,y_start_ceil,y_start_ceil];
fill(x_data,y_data,[0,1,0]);
start = start_new;
data = '起点是%4.0f\\n';
fprintf(data,start)
% set(handles.edit2,'string',start)
end
% function test(hObject, eventdata, handles)
% global start start_new
% if start~=start_new
% set(hanles.edit2,'value',start_new)
% end
% 画终点的函数
function figure_goal(goal_new)
global barrier goal
if goal_new~=goal
X = size(barrier,1);
Y = size(barrier,2);
% 清除以前的点的消息
x_goal = ( mod(goal-1,X) +1-0.5);
y_goal = ( Y- ceil(goal/Y) +1-0.5);
x_start_floor = floor(x_goal);
x_start_ceil = ceil(x_goal);
y_start_floor = floor(y_goal);
y_start_ceil = ceil(y_goal);
x_data = [x_start_floor,x_start_ceil,x_start_ceil,x_start_floor];
y_data = [y_start_floor,y_start_floor,y_start_ceil,y_start_ceil];
fill(x_data,y_data,[1,1,1]);
%% 画新的点
x_goal_new = ( mod(goal_new-1,X) +1-0.5);
y_goal_new = ( Y- ceil(goal_new/Y) +1-0.5);
x_start_floor = floor(x_goal_new);
x_start_ceil = ceil(x_goal_new);
y_start_floor = floor(y_goal_new);
y_start_ceil = ceil(y_goal_new);
x_data = [x_start_floor,x_start_ceil,x_start_ceil,x_start_floor];
y_data = [y_start_floor,y_start_floor,y_start_ceil,y_start_ceil];
fill(x_data,y_data,[1,0,0]);
goal = goal_new;
end
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% 画终点
global permission_goal
permission_goal = 1;
set(handles.edit2,'string',[])
set(handles.edit3,'string',[])
axes(handles.axes1);
if permission_goal==1
set(handles.edit38,'string','选择起点结束后请点击结束按钮,否则易出错');
s.hf = get(handles.axes1,'parent');
set(s.hf,'WindowButtonDownFcn',@figure1_windowbuttondownfcn_point_goal);
end
global goal
figure_goal(goal);
function figure1_windowbuttondownfcn_point_goal(hobj,event)
global barrier
X = size(barrier,1);
Y = size(barrier,2);
global permission_goal
if permission_goal==1
if strcmp(get(hobj,'SelectionType'),'normal')
p = get(gca,'currentpoint'); % 取鼠标当前所在点的坐标
x(1) = p(1);% 当前点的横坐标;
x_ceil = ceil(x(1));
y(1) = p(3);% 当前点的纵坐标
y_ceil = ceil(y(1));
point_goal = [x_ceil,y_ceil];
goal = point_goal(1) + ( Y-point_goal(2) )*X;
figure_goal(goal);
data = '终点是%4.0f\\n';
fprintf(data,goal)
end
end
function edit5_Callback(hObject, eventdata, handles)
% hObject handle to edit201 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit201 as text
% str2double(get(hObject,'String')) returns contents of edit201 as a double
% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit201 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit6_Callback(hObject, eventdata, handles)
% hObject handle to edit202 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit202 as text
% str2double(get(hObject,'String')) returns contents of edit202 as a double
% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit202 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit7_Callback(hObject, eventdata, handles)
% hObject handle to edit203 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit203 as text
% str2double(get(hObject,'String')) returns contents of edit203 as a double
% --- Executes during object creation, after setting all properties.
function edit7_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit203 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit8_Callback(hObject, eventdata, handles)
% hObject handle to edit204 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit204 as text
% str2double(get(hObject,'String')) returns contents of edit204 as a double
% --- Executes during object creation, after setting all properties.
function edit8_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit204 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit9_Callback(hObject, eventdata, handles)
% hObject handle to edit9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit9 as text
% str2double(get(hObject,'String')) returns contents of edit9 as a double
% --- Executes during object creation, after setting all properties.
function edit9_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit10_Callback(hObject, eventdata, handles)
% hObject handle to edit10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit10 as text
% str2double(get(hObject,'String')) returns contents of edit10 as a double
% --- Executes during object creation, after setting all properties.
function edit10_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in radiobutton4.
function radiobutton4_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton4
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global reason start goal
global h_waitbar
set(handles.edit57,'string',1);set(handles.edit58,'string',1);set(handles.edit59,'string',1);
set(handles.edit60,'string',1);set(handles.edit61,'string',1);
set(handles.edit2,'string',start);
set(handles.edit3,'string',goal);
set(handles.edit38,'string','正在运行');
set(handles.text60,'visible','off')
tic;
h_waitbar = waitbar(0,'正在运行,请稍后...');
if reason == 1 % 如果是第一个目的,即选择一种算法进行分析,则选择一种算法运行
prime_only_one_algorithm(hObject, eventdata, handles)
elseif reason==2 % 如果是第二个目的,即选择多种算法进行分析
prime_multi_algorithm(hObject, eventdata, handles)
end
delete(h_waitbar);
time_algorithm = round(toc);
tip_time = ['运行结束,已运行',num2str(time_algorithm),'秒'];
set(handles.edit38,'string',tip_time);
function edit91_Callback(hObject, eventdata, handles)
% hObject handle to edit91 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit91 as text
% str2double(get(hObject,'String')) returns contents of edit91 as a double
% --- Executes during object creation, after setting all properties.
function edit91_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit91 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit12_Callback(hObject, eventdata, handles)
% hObject handle to edit12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit12 as text
% str2double(get(hObject,'String')) returns contents of edit12 as a double
% --- Executes during object creation, after setting all properties.
function edit12_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit13_Callback(hObject, eventdata, handles)
% hObject handle to edit13 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit13 as text
% str2double(get(hObject,'String')) returns contents of edit13 as a double
% --- Executes during object creation, after setting all properties.
function edit13_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit13 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit14_Callback(hObject, eventdata, handles)
% hObject handle to edit14 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit14 as text
% str2double(get(hObject,'String')) returns contents of edit14 as a double
% --- Executes during object creation, after setting all properties.
function edit14_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit14 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit92_Callback(hObject, eventdata, handles)
% hObject handle to edit92 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit92 as text
% str2double(get(hObject,'String')) returns contents of edit92 as a double
% --- Executes during object creation, after setting all properties.
function edit92_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit92 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit16_Callback(hObject, eventdata, handles)
% hObject handle to edit16 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit16 as text
% str2double(get(hObject,'String')) returns contents of edit16 as a double
% --- Executes during object creation, after setting all properties.
function edit16_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit16 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit94_Callback(hObject, eventdata, handles)
% hObject handle to edit94 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit94 as text
% str2double(get(hObject,'String')) returns contents of edit94 as a double
% --- Executes during object creation, after setting all properties.
function edit94_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit94 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit18_Callback(hObject, eventdata, handles)
% hObject handle to edit18 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit18 as text
% str2double(get(hObject,'String')) returns contents of edit18 as a double
% --- Executes during object creation, after setting all properties.
function edit18_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit18 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in radiobutton5.
function radiobutton5_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton5
set(handles.uipanel200,'visible','on')
set(handles.uipanel201,'visible','off')
set(handles.uipanel202,'visible','off')
set(handles.uipanel203,'visible','off')
set(handles.uipanel204,'visible','off')
% --- Executes on button press in radiobutton6.
function radiobutton6_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton6
set(handles.uipanel200,'visible','off')
set(handles.uipanel201,'visible','off')
set(handles.uipanel202,'visible','off')
set(handles.uipanel203,'visible','on')
set(handles.uipanel204,'visible','off')
% --- Executes on button press in radiobutton7.
function radiobutton7_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton7
set(handles.uipanel200,'visible','off')
set(handles.uipanel201,'visible','off')
set(handles.uipanel202,'visible','off')
set(handles.uipanel203,'visible','off')
set(handles.uipanel204,'visible','on')
% --- Executes when figure1 is resized.
function figure1_ResizeFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
function edit93_Callback(hObject, eventdata, handles)
% hObject handle to edit93 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit93 as text
% str2double(get(hObject,'String')) returns contents of edit93 as a double
% --- Executes during object creation, after setting all properties.
function edit93_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit93 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit24_Callback(hObject, eventdata, handles)
% hObject handle to edit24 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit24 as text
% str2double(get(hObject,'String')) returns contents of edit24 as a double
% --- Executes during object creation, after setting all properties.
function edit24_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit24 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit25_Callback(hObject, eventdata, handles)
% hObject handle to edit25 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit25 as text
% str2double(get(hObject,'String')) returns contents of edit25 as a double
% --- Executes during object creation, after setting all properties.
function edit25_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit25 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit26_Callback(hObject, eventdata, handles)
% hObject handle to edit26 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit26 as text
% str2double(get(hObject,'String')) returns contents of edit26 as a double
% --- Executes during object creation, after setting all properties.
function edit26_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit26 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit27_Callback(hObject, eventdata, handles)
% hObject handle to edit27 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit27 as text
% str2double(get(hObject,'String')) returns contents of edit27 as a double
% --- Executes during object creation, after setting all properties.
function edit27_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit27 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit28_Callback(hObject, eventdata, handles)
% hObject handle to edit28 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit28 as text
% str2double(get(hObject,'String')) returns contents of edit28 as a double
% --- Executes during object creation, after setting all properties.
function edit28_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit28 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit101_Callback(hObject, eventdata, handles)
% hObject handle to edit101 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit101 as text
% str2double(get(hObject,'String')) returns contents of edit101 as a double
% --- Executes during object creation, after setting all properties.
function edit101_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit101 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit102_Callback(hObject, eventdata, handles)
% hObject handle to edit102 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit102 as text
% str2double(get(hObject,'String')) returns contents of edit102 as a double
% --- Executes during object creation, after setting all properties.
function edit102_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit102 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit104_Callback(hObject, eventdata, handles)
% hObject handle to edit104 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit104 as text
% str2double(get(hObject,'String')) returns contents of edit104 as a double
% --- Executes during object creation, after setting all properties.
function edit104_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit104 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit105_Callback(hObject, eventdata, handles)
% hObject handle to edit105 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit105 as text
% str2double(get(hObject,'String')) returns contents of edit105 as a double
% --- Executes during object creation, after setting all properties.
function edit105_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit105 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit106_Callback(hObject, eventdata, handles)
% hObject handle to edit106 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit106 as text
% str2double(get(hObject,'String')) returns contents of edit106 as a double
% --- Executes during object creation, after setting all properties.
function edit106_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit106 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in radiobutton9.
function radiobutton9_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton9
% --- Executes on button press in radiobutton10.
function radiobutton10_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton10
% --- Executes on button press in pushbutton9.
function pushbutton9_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton10.
function pushbutton10_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton11.
function pushbutton11_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
function edit34_Callback(hObject, eventdata, handles)
% hObject handle to edit34 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit34 as text
% str2double(get(hObject,'String')) returns contents of edit34 as a double
% --- Executes during object creation, after setting all properties.
function edit34_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit34 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit35_Callback(hObject, eventdata, handles)
% hObject handle to edit35 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit35 as text
% str2double(get(hObject,'String')) returns contents of edit35 as a double
% --- Executes during object creation, after setting all properties.
function edit35_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit35 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in radiobutton11.
function radiobutton11_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton11
% --- Executes on button press in radiobutton12.
function radiobutton12_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton12
% --- Executes on button press in pushbutton12.
function pushbutton12_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_1_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
function figure1_windowbuttondownfcn(hobj,event)
% point_data 输出,输出当前的一个点
% 定义figure的回调函数
global draw_enable x y data barrier pushbutton1_userdata
% if pushbutton1_userdata == 0
% set(handles.edit38,'string','如果需要设计障碍物图形,请先点击设计障碍物按钮');
% disp('如果需要设计障碍物图形,请先点击设计障碍物按钮')
if pushbutton1_userdata ==1
n_barrier = size(barrier,1);
% 若figure的selectiontype属性值为normal,则表示单击鼠标左键
if strcmp(get(hobj,'SelectionType'),'normal')
draw_enable = 1;
p = get(gca,'currentpoint'); % 取鼠标当前所在点的坐标
x(1) = p(1);% 当前点的横坐标
x1_floor = floor(x(1));
x1_ceil = ceil(x(1));
y(1) = p(3);% 当前点的纵坐标
y1_floor = floor(y(1));
y1_ceil = ceil(y(1));
data = [x1_floor,y1_floor;...
x1_ceil,y1_floor;...
x1_ceil,y1_ceil;...
x1_floor,y1_ceil]; % 依次取该点的周围四个顶点
x_data = [x1_floor,x1_ceil,x1_ceil,x1_floor];
y_data = [y1_floor,y1_floor,y1_ceil,y1_ceil];
fill(x_data,y_data,[0,0,0]); % 填充这个方格为黑色
% 设置这个方格不可用,即设置barrier中对应方格为1(表示该方格是障碍)
y1_ceil_temp = n_barrier - y1_ceil + 1;
barrier(y1_ceil_temp,x1_ceil) = 1;
end
% 如果figure的selectiontype属性值为alt,则表示双击鼠标,使方格为白色,可以安全行走
if strcmp(get(hobj,'selectiontype'),'open')
draw_enable = 0;
p = get(gca,'currentpoint'); % 取鼠标当前所在点的坐标
x(1) = p(1);% 当前点的横坐标
x1_floor = floor(x(1));
x1_ceil = ceil(x(1));
y(1) = p(3);% 当前点的纵坐标
y1_floor = floo以上是关于路径规划基于蚁群算法栅格地图路径规划matlab的主要内容,如果未能解决你的问题,请参考以下文章
路径规划基于matlab GUI多种蚁群算法栅格地图路径规划含Matlab源码 650期
路径规划基于matlab蚁群算法求解机器人栅格地图最短路径规划问题含Matlab源码 1618期