mutateoper.m
来自「基本遗传算法的matlab源程序」· M 代码 · 共 27 行
M
27 行
function geneCodMut=mutateOper(geneCod,proMut)
% mutation operator
% syntax:geneCodMut=mutateOper(geneCod,proMut)
%
% Output Arguments:
% geneCode ---- a matrix of chromosome codes
% Input Arguments:
% geneCodMut ---- a matrix of chromosome codes after mutation
% proMut ---- the probability of gene mutation
%
% Author:Yan Anxin
% ID number:081810
% Yax235 DreamWorks, SEE, SEU, 2# Sipailou Nanjing, 210096, P.R.China
[sizePop,sizeGene]=size(geneCod);
geneCodMut=geneCod;
for ik=1:(sizePop*sizeGene)
proRand=rand(1);
if proRand>proMut,continue;end %random variation
geneCodMut(ik)=num2str(1-bin2dec(geneCodMut(ik)));
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?