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

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

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

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

if ~isallpass(h),
    error('The filter to convert must have allpass sections.');
end
    
for n = 1:nsections(h),
    
    hsec = section(h,n);
           
    [num{n},den{n}] = tf(hsec);   
       
    k{n} = tf2latc(num{n},den{n});
    newsection{n} = {k{n}};
end

connect = connection(h);

f = latcallpass(newsection,connect);

