function X = plus(X,Y)
%PLUS Merges two LMI objects to one LMI
% Author Johan L鰂berg
% $Id: plus.m,v 1.8 2005/02/10 16:43:32 johanl Exp $
if ~((isa(X,'lmi')) & (isa(Y,'lmi')))
error('Both arguments must be SET objects')
end
nX = length(X.clauses);
nY = length(Y.clauses);
if nX+nY == 0
return
end
X.clauses = {X.clauses{:},Y.clauses{:}};
X.LMIid = [X.LMIid Y.LMIid];
% VERY FAST UNIQUE BECAUSE THIS IS CALLED A LOT OF TIMES....
i = sort(X.LMIid);
i = i(diff([i NaN])~=0);
if length(i) [i,j] = unique(X.LMIid);
X = subsref(X,struct('type','()','subs',{{j}}));
end