function ismaxphaseflag = ismaxphase(f,sec)
%ISMAXPHASE  Determine if filter object has maximum-phase sections.
%   FLAG = ISMAXPHASE(F) determines if the filter object F has
%   maximum-phase filter sections, and returns 1 if true and 0 if
%   false.
%
%   FLAG = ISMAXPHASE(F,I) determines if the I-th section of the
%   filter object F is a maximum-phase section and returns 1 if true
%   and 0 if false.
%
%   See also DFILT/ISMINPHASE, DFILT/ISLINPHASE, DFILT/ISFIR,
%   DFILT/ISSTABLE, DFILT/ISALLPASS.

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

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

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

ismaxphaseflag = 1; % Initialized assuming maximum-phase
n = 1;

while ismaxphaseflag & n <= nsections(f),
    
    fsec = section(f,n);
    
    if ~isa(fsec,'latcmax'),
        % We check if each section is latcmax for the case of cas and par filters
       
        [b,a] = tf(fsec);
        
        ftemp = df2t(conj(b(end:-1:1)));
        
        % Check if conjugated and reversed polynomial is minimum-phase
        if ~isminphase(ftemp),
            ismaxphaseflag = 0;
        end
        
    end
    
    n = n + 1;
    
end

   
