📄 antsgui.m
字号:
function varargout = AntsGui(varargin)
% ANTSGUI M-file for AntsGui.fig
% ANTSGUI, by itself, creates a new ANTSGUI or raises the existing
% singleton*.
%
% H = ANTSGUI returns the handle to a new ANTSGUI or the handle to
% the existing singleton*.
%
% ANTSGUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in ANTSGUI.M with the given input arguments.
%
% ANTSGUI('Property','Value',...) creates a new ANTSGUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before AntsGui_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to AntsGui_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 AntsGui
% Last Modified by GUIDE v2.5 03-Jun-2007 16:23:54
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @AntsGui_OpeningFcn, ...
'gui_OutputFcn', @AntsGui_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin & isstr(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 AntsGui is made visible.
function AntsGui_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 AntsGui (see VARARGIN)
% Choose default command line output for AntsGui
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes AntsGui wait for user response (see UIRESUME)
% uiwait(handles.figure1);
global AntsCod
global bContinue
bContinue = 0;
CityNum = str2num(get(handles.CityNum,'String'));
AntsCod =zeros(CityNum,2);
%if MapIndex == 1
AntsCod(:,1) = (unidrnd(600,1,CityNum) - 1)';
AntsCod(:,2) = (unidrnd(450,1,CityNum) - 1)';
plot(AntsCod(:,1),AntsCod(:,2),'o:','Parent',handles.MapCurver);
% --- Outputs from this function are returned to the command line.
function varargout = AntsGui_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 during object creation, after setting all properties.function MapProperty_CreateFcn(hObject, eventdata, handles)% hObject handle to MapProperty (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 set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end% --- If Enable == 'on', executes on mouse press in 5 pixel border.% --- Otherwise, executes on mouse press in 5 pixel border or over MapProperty.function MapProperty_ButtonDownFcn(hObject, eventdata, handles)% hObject handle to MapProperty (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% --- Executes on selection change in MapProperty.function MapProperty_Callback(hObject, eventdata, handles)% hObject handle to MapProperty (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: contents = get(hObject,'String') returns MapProperty contents as cell array% contents{get(hObject,'Value')} returns selected item from MapProperty% --- Executes during object creation, after setting all properties.function CityNum_CreateFcn(hObject, eventdata, handles)% hObject handle to CityNum (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 set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction CityNum_Callback(hObject, eventdata, handles)% hObject handle to CityNum (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 CityNum as text% str2double(get(hObject,'String')) returns contents of CityNum as a double% --- Executes during object creation, after setting all properties.function AntsNum_CreateFcn(hObject, eventdata, handles)% hObject handle to AntsNum (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 set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction AntsNum_Callback(hObject, eventdata, handles)% hObject handle to AntsNum (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 AntsNum as text% str2double(get(hObject,'String')) returns contents of AntsNum as a double% --- Executes on button press in Reset.function Reset_Callback(hObject, eventdata, handles)% hObject handle to Reset (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)
global AntsCod
global bContinue
bContinue = 0;
%MapIndex = get(handles.MapProperty,'Value');
CityNum = str2num(get(handles.CityNum,'String'));
AntsCod =zeros(CityNum,2);
%if MapIndex == 1
AntsCod(:,1) = (unidrnd(600,1,CityNum) - 1)';
AntsCod(:,2) = (unidrnd(450,1,CityNum) - 1)';
plot(AntsCod(:,1),AntsCod(:,2),'o:','Parent',handles.MapCurver);
cla(handles.DistanceCurver);
set(handles.AntsNum,'Enable','on')
set(handles.AntsColonyNum,'Enable','on')
set(handles.PheromCoe,'Enable','on')
set(handles.DistCoe,'Enable','on')
set(handles.PhoremEvapCoe,'Enable','on')
set(handles.PheromAddCoe,'Enable','on')
%end% --- Executes during object creation, after setting all properties.function AntsColonyNum_CreateFcn(hObject, eventdata, handles)% hObject handle to AntsColonyNum (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 set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction AntsColonyNum_Callback(hObject, eventdata, handles)% hObject handle to AntsColonyNum (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 AntsColonyNum as text% str2double(get(hObject,'String')) returns contents of AntsColonyNum as a double% --- Executes during object creation, after setting all properties.function PheromCoe_CreateFcn(hObject, eventdata, handles)% hObject handle to PheromCoe (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 set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction PheromCoe_Callback(hObject, eventdata, handles)% hObject handle to PheromCoe (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 PheromCoe as text% str2double(get(hObject,'String')) returns contents of PheromCoe as a double
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -