function B = ds2lti(A,Ts)

% Copyright 2003-2004 The MathWorks, Inc.

B = lti;
IG = pvget(A,'InputGroup');
if isa(IG,'struct')
   f = fieldnames(IG);
   AIG = cell(length(f),2);
   for i=1:length(f)
      AIG{i,1} = getfield(IG,f{i});
      AIG{i,2} = f{i};
   end
elseif isa(IG,'cell')
   AIG = IG;
else
   error('Invalid InputGroup');
end
OG = pvget(A,'OutputGroup');
if isa(OG,'struct')
   f = fieldnames(OG);
   AOG = cell(length(f),2);
   for i=1:length(f)
      AOG{i,1} = getfield(OG,f{i});
      AOG{i,2} = f{i};
   end
elseif isa(OG,'cell')
   AOG = OG;
else
   error('Invalid OutputGroup');
end
InNam = pvget(A,'InputName');
OutNam = pvget(A,'OutputName');
nu = size(InNam,1);
ny = size(OutNam,1);
ioDelay = zeros(ny,nu);
InputDelay = zeros(nu,1);
OutputDelay = zeros(ny,1);

B = pvset(B,...
    'Ts',Ts,...
    'InputGroup',AIG,...
    'OutputGroup',AOG,...
    'InputName',InNam,...
    'OutputName',OutNam);
set(B,...
    'ioDelay',ioDelay,...
    'InputDelay',InputDelay,...
    'OutputDelay',OutputDelay,...
    'Notes',pvget(A,'Notes'),...
    'UserData',pvget(A,'UserData'));
