www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgoptimextoptions/importConstraint.m

    function obj = importConstraint(obj,otherobj,index)
%IMPORTCONSTRAINT import constraint 
%
%  IMPORTCONSTRAINT(OBJ,OTHEROBJ,INDEX) import constraint from another
%  optimization. 

%  Copyright 2008-2009 The MathWorks, Inc.

if ~canAddConstraint(obj)
    error(message('mbc:cgoptim:InvalidState'));
end
coninfo = otherobj.constraints.details;
newcon = coninfo(index);
% make label unique
newcon.label = generateLabel(obj, newcon.label, 'allowroot');

obj.constraints.details(end+1) = newcon;