function [a,b,c,d] = addss(Z1,Z2,Z3,Z4,Z5,Z6,Z7,Z8)
%
% [SS_] = ADDSS(SS_1,SS_2) or
% [A,B,C,D] = ADDSS(A1,B1,C1,D1,A2,B2,C2,D2) add two state-space realization:
%
%                                           -1
%             G(s) = G1(s) + G2(s) = C(Is-A)  B + D
%       where
%                              -1
%             G1(s) = C1(Is-A1)  B1 + D1,  SS_1 = SYSTEM(A1,B1,C1,D1)
%
%                              -1
%             G2(s) = C2(Is-A2)  B2 + D2,  SS_2 = SYSTEM(A2,B2,C2,D2);

% R. Y. Chiang & M. G. Safonov 8/85
% Copyright (c) 1988 by the MathWorks, Inc.
% All Rights Reserved.

inargs='(a1,b1,c1,d1,a2,b2,c2,d2)';
eval(mkargs(inargs,nargin,'ss'))

[rb1,cb1] = size(b1);
[rc1,cc1] = size(c1);
[rb2,cb2] = size(b2);
[rc2,cc2] = size(c2);
%
if (cb1 ~= cb2) + (rc1 ~= rc2)
   ERROR = 'TWO SYSTEMS ARE NOT COMPATIABLE !'
   return
end
%
a = [a1 zeros(rb1,cc2); zeros(rb2,cc1) a2];
b = [b1;b2];
c = [c1 c2];
d = d1 + d2;

if xsflag 
   a = mksys(a,b,c,d);
end
%
% ----- End of ADDSS.CTR ---- RYC/MGS 8/85%
