function varargout = lattice(h,sec)
%LATTICE  Convert a dfilt object to lattice/ladder coefficients.
%   K = LATTICE(H) finds the lattice coefficients K of an FIR (MA)
%   lattice filter structure, given any DFILT filter object H that
%   corresponds to an FIR filter.  The FIR filter must be either
%   minimum-phase or maximum-phase.
%
%   [K,V] = LATTICE(H) finds the lattice coefficients K and the ladder
%   coefficients V of an IIR (ARMA) lattice-ladder filter structure,
%   given any DFILT object H.
%
%   K = LATTICE(H) finds the lattice coefficients K of an IIR
%   all-pole (AR) lattice filter structure, given a DFILT object H
%   with all zeros at the origin.
%
%   K = LATTICE(H) finds the lattice coefficients K of an
%   allpass lattice filter structure, given a DFILT object H
%   corresponding to an allpass filter.
%
%   [...] = LATTICE(H,I) finds the lattice coefficients corresponding
%   to the I-th section of the DFILT object H.

%   Author(s): R. Losada
%   Copyright 1988-2000 The MathWorks, Inc.
%   $Revision: 1.4 $  $Date: 2000/09/11 15:41:48 $ 

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

% Convert to transfer function first
[b,a] = tf(h);

if ismaxphase(h) & isfir(h),
	
	[varargout{1:nargout}] = tf2latc(b,a,'max');
else
	[varargout{1:nargout}] = tf2latc(b,a);
end

% EOF
