总是会面临,根据选择的不同的值,获得不同 函数。就类似于switch 中的问题
switch F
case 'F1'
fobj = @F1;
lb=-100;
ub=100;
dim=30;
case 'F2'
fobj = @F2
lb=-10;
ub=10;
dim=30;
end
function o = F1(x)
% o = sum(x.^2); This is the advantage of matrix
o=sum((x).^2);
end
% F2
function o = F2(x)
o=sum(abs(x))+prod(abs(x));
end