function [ds,Ts] = lti2ds(A)

% Copyright 2003-2004 The MathWorks, Inc.

switch class(A)
case 'lti'
   ds = dynamicsys;
    AIG = get(A,'InputGroup');
    AOG = get(A,'OutputGroup');
    if isa(AIG,'cell')
       tmp = AIG(:,[2 1]).';
       AIG = struct(tmp{:});
    end
    if isa(AOG,'cell')
       tmp = AOG(:,[2 1]).';
       AOG = struct(tmp{:});
    end
    ds = pvset(ds,...
        'InputGroup',AIG,...
        'OutputGroup',AOG,...
        'InputName',get(A,'InputName'),...
        'OutputName',get(A,'OutputName'),...
        'Notes',get(A,'Notes'),...
        'UserData',get(A,'UserData'));
    Ts = get(A,'Ts');
case {'ss' 'zpk' 'tf' 'frd'}
    tmp = struct(A);
    A = tmp.lti;
    [ds,Ts] = lti2ds(A);
otherwise
    error(['Conversion to DS not possible from class ' class(A)]);
end