www.gusucode.com > GAVPai_Book_MathworksCntrlFileEx_May2019 > GAVPai_Book_MathworksCntrlFileEx_May2019/group_assets_130_30.m

    

function C = group_assets_130_30(individual_size, individual) 

M = cell(1, 2);
p = 1;
N = [1:individual_size];
    for c = 1:individual_size
        if (individual(c) >= 0) 
         M{1}(p)=c;
         p = p+1;
        end 
    end
    if (length(M{1})==0)
        disp('Empty long positions')
        C{1}= [];
        C{2}= N;
        
    else C{1} = M{1};
         C{2} = setdiff(N,M{1});
    end
end