compgaps.m

来自「Passino所提出的细菌优化算法matlab源程序」· M 代码 · 共 18 行

M
18
字号
function gaps = compgaps(frogs)
% Computes the angular difference between two consecutive frogs

global N gaps

for i = 1: N
    i1 = mod(i,N);
    i2 = mod(i+1,N);
    if i1 == 0          %This handles the case for the computation of the gap of the Nth frog
        gaps(i) = get(frogs(i2),'angle')-get(frogs(i),'angle')+360; %Calls the get method in the directory @frogc
    elseif i2 == 0      %This handles the case for the computation of the gap of the (N-1)th frog
        gaps(i) = get(frogs(N),'angle')-get(frogs(i),'angle');
    else
        gaps(i) = get(frogs(i+1),'angle')-get(frogs(i),'angle');
    end
    
end
return

⌨️ 快捷键说明

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