⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sort.m

📁 Passino所提出的细菌优化算法matlab源程序
💻 M
字号:
function [frogs] = sort(frogs)
% Sort in ascending order the angles of frogp object ant its associate fields (ID, angle, gap, supergap)

global N

for i = 1: N
    % Gets the angles from frogs
    tmp_angle(i) = get(frogs(i),'angle');
end
%Sorts them and stores their indices
[tmp_angle,ind]=sort(tmp_angle);

temp = frogs;
%Now stores the angles in ascendent order with all their fields
for i = 1:N
    %Two methods are called here: set is called first and then subsasgn is called
    frogs(i) = set(temp(i), 'ID', get(temp(ind(i)),'ID'), 'angle', get(temp(ind(i)),'angle'),...
        'gap', get(temp(ind(i)),'gap'), 'supergap', get(temp(ind(i)),'supergap'));
end
return

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -