www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/@conrange/or.m
function con = or(con1, con2) %OR Logical OR (union) of two range constraints % % CON = OR(CON1, CON2) is the union of the constraints CON1 and CON2, i.e., a % point X is in OR(CON1,CON2) if and only if it is inside CON1 or it is inside % CON2. % % CON1 and CON2 must be the have the same number of input factors (as returned % by NINPUTFACTORS). % % If either CON1 or CON2 is not a range constraint (CONRANGE) then CON1 & CON2 % will be a boolean constraint (CONBOOLEAN). % % See also CONRANGE, CONBASE/OR. % Copyright 2000-2005 The MathWorks, Inc. % Can only combine if both constraints are rnage constraints. Otherwise, just % redirect to conboolean if ~isa( con1, 'conrange' ) || ~isa( con2, 'conrange' ), con = conboolean( 'Or', con1, con2 ); return end % We get the upper and lower bounds for each constraint and then take min's and % max's to get the range of the overall constraint. We also need to check for % inactive (+/-inf in the range) factors. [A1, B1] = getRange( con1 ); [A2, B2] = getRange( con2 ); con = setRange( con1, min( A1, A2 ), max( B1, B2 ) ); %------------------------------------------------------------------------------| % EOF %------------------------------------------------------------------------------|