function D1 = iocat(dim,D1,D2)
% Concatenates models along input (2) or output (1) dimension.

%   Copyright 1986-2020 The MathWorks, Inc.
if isfinite(D1) && isfinite(D2)
   D1 = iocat@ltipack.AbstractSS(dim,D1,D2);
   D1.StateInfo = [D1.StateInfo;D2.StateInfo];
   D1.SolverConfig = ltioptions.sparss.reconcile(D1.SolverConfig,D2.SolverConfig);
else
   % One system is NaN
   [ny1,nu1] = iosize(D1);
   [ny2,nu2] = iosize(D2);
   if dim==1
      D1 = createGain(D1,NaN(ny1+ny2,nu1));
   else
      D1 = createGain(D1,NaN(ny1,nu1+nu2));
   end
end