📄 ww.m
字号:
function varargout = ww(varargin)% WW M-file for ww.fig% WW, by itself, creates a new WW or raises the existing% singleton*.%% H = WW returns the handle to a new WW or the handle to% the existing singleton*.%% WW('Property','Value',...) creates a new WW using the% given property value pairs. Unrecognized properties are passed via% varargin to ww_OpeningFcn. This calling syntax produces a% warning when there is an existing singleton*.%% WW('CALLBACK') and WW('CALLBACK',hObject,...) call the% local function named CALLBACK in WW.M with the given input% arguments.%% *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 ww% Last Modified by GUIDE v2.5 26-May-2006 15:54:40% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @ww_OpeningFcn, ... 'gui_OutputFcn', @ww_OutputFcn, ... 'gui_LayoutFcn', [], ... 'gui_Callback', []);if nargin & isstr(varargin{1}) gui_State.gui_Callback = str2func(varargin{1});endif 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 ww is made visible.function ww_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 unrecognized PropertyName/PropertyValue pairs from the% command line (see VARARGIN)% Choose default command line output for wwhandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes ww wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = ww_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 structurevarargout{1} = handles.output;% --- 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)popsize=80; %设置初始参数,群体大小chromlength=20; %字符串长度(个体长度),染色体长度pc=0.6; %设置交叉概率,本%交叉概率函数,例如用神经网络训练得到的值作为交叉概率pm=0.02; %设置变异概率,同理也可设置为变化的pop=initpop(popsize,chromlength); %运行初始化函数,随机产生初始群体for i=1:400%4000为迭代次数[objvalue]=calobjvalue(pop);%计算目标函数fitvalue=calfitvalue(objvalue); %计算群体中每个个体的适应度[newpop]=selection(pop,fitvalue); %复制[newpop]=crossover(newpop,pc); %交叉[newpop]=mutation(newpop,pm);%变异[leastindividual,leastfit]=least(newpop,fitvalue);%求出群体中适应值最大的个体及其适应值y=leastfit;n(i)=i;pop5=leastindividual;x1=decodechrom(pop5,11,chromlength)*10/1023;x2=decodechrom1(pop5,1,chromlength-10)*10/1023;pop=newpop;endy x1x2% --- 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)% --- 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)close(rr)close(ww)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -