sort.m
来自「一些经典遗传算法问题的matlab程序调度问题分配问题等等」· M 代码 · 共 13 行
M
13 行
function varargout = sort(chr)
% SORT - Sort in ascending order. For a vector of chromosomes, sort(x)
% sorts the objects of x in ascending order, with the respect to
% the fitness of the chromosomes.
% [y i] = sort(x) also returns an index vector.
for k=1:length(chr)
tmp(k)=chr(k).fitness;
end
[q ind]=sort(tmp);
varargout{1}=chr(ind);
varargout{2}=ind;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?