function f = latcarma(h,sec)
%LATCARMA   Convert a DFILT object to a LATCARMA object.
%   G = LATCARMA(H) returns a LATCARMA filter object G given
%   a DFILT object H with IIR sections.
%
%   G = LATCARMA(H,I) converts the I-th section of H to a
%   LATCARMA filter object.

%   Author(s): R. Losada
%   Copyright 1988-2000 The MathWorks, Inc.
%   $Revision: 1.7 $  $Date: 2000/06/13 21:23:57 $

error(nargchk(1,2,nargin));

if nargin == 2,
    h = section(h,sec);
end

for n = 1:nsections(h),
    
    hsec = section(h,n);
    
    [num{n},den{n}] = tf(hsec);
    
    [k{n},v{n}] = tf2latc(num{n},den{n});
           
    newsection{n} = {k{n},v{n}};
end

connect = connection(h);

f = latcarma(newsection,connect);

