addbounds.m
来自「matlab波形优化算法经常要用到的matlab toolbox工具箱:yalm」· M 代码 · 共 35 行
M
35 行
function [F_struc,K] = addbounds(F_struc,K,ub,lb)
%ADDBOUNDS Internal function to add variable bounds to an F_struc
% Author Johan L鰂berg
% $Id: addbounds.m,v 1.3 2005/02/10 16:43:32 johanl Exp $
% Upper bounds
finite_bounds = find(~isinf(ub));
if ~isempty(finite_bounds)
p = length(finite_bounds);
n = length(ub);
if ~isempty(F_struc)
F_struc = [F_struc(1:1:K.f,:);[ub(finite_bounds) -sparse(1:p,finite_bounds,ones(p,1),p,n)];F_struc(K.f+1:end,:)];
else
F_struc = [ub(finite_bounds) -sparse(1:p,finite_bounds,ones(p,1),p,n)];
end
K.l = K.l+p;
end
% Lower bounds
finite_bounds = find(~isinf(lb));
if ~isempty(finite_bounds)
p = length(finite_bounds);
n = length(ub);
if ~isempty(F_struc)
F_struc = [F_struc(1:1:K.f,:);[-lb(finite_bounds) sparse(1:p,finite_bounds,ones(p,1),p,n)];F_struc(K.f+1:end,:)];
else
F_struc = [[-lb(finite_bounds) sparse(1:p,finite_bounds,ones(p,1),p,n)];F_struc(K.f+1:end,:)];
end
K.l = K.l+p;
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?