www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/@conboolean/or.m
function c = or( c, c2 ) %OR Logical OR of two constraints (union of two constraints) % % C = OR(C1,C2) is the union of the constraints C1 and C2, i.e., a point X % is in OR(C1,C2) if and only if it is inside C1 or it is inside C2. % % C1 and C2 must be the same size (as returned by GETSIZE) % % See also CONBASE/NOT, CONBASE/AND, CONBASE/XOR, CONBOOLEAN, GETSIZE. % Copyright 2000-2005 The MathWorks, Inc. and Ford Global Technologies, Inc. % check n input factors to constraints if nFactors( c ) ~= nFactors( c2 ), error(message('mbc:conboolean:InvalidArgument')); end % To keep things simple, we want to ensure that % c is a conboolean % c2 is any conbase object if ~isa( c, 'conboolean' ), [c2, c] = deal( c, c2 ); % swap c and c2 end if isa( c2, 'conboolean' ), if strcmpi( c.Op, 'Or' ) && strcmpi( c2.Op, 'Or' ) && ~c.Not && ~c2.Not, c.Constraints = [ c.Constraints, c2.Constraints ]; elseif strcmpi( c.Op, 'Or' ) && ~c.Not, c.Constraints{end+1} = c2; elseif strcmpi( c2.Op, 'Or' ) && ~c2.Not, [c2, c] = deal( c, c2 ); % swap c and c2 c.Constraints{end+1} = c2; else c = conboolean( 'Or', c, c2 ); end else if strcmpi( c.Op, 'Or' ) && ~c.Not, c.Constraints{end+1} = c2; else c = conboolean( 'Or', c, c2 ); end end