function h = dtf(varargin)
%DTF  Constructor for the discrete transfer function object.
%   F = DTF(B,A) creates a discrete transfer function (DTF)
%   object F with numerator coefficients specified in vector
%   B and denominator coefficients specified in vector A.
%
%   F = DTF(B1,A1,B2,A2,...) creates a DTF object F of
%   cascaded sections. The numerator and denominator of the
%   i-th section are given by the coefficients in vectors Bi
%   and Ai respectively.
%
%   F = DTF({{B1,A1},{B2,A2},...}) is equivalent to
%   F = DTF(B1,A1,B2,A2,...).
%
%   F = DTF(...,C) creates a DTF object of sections connected
%   as indicated in C.  C can be either 'cas' (default) for
%   cascaded connections or 'par' for parallel connections.

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

[coeffs,connection,msg] = dfiltparse('dtf',varargin{:});

% If msg returns with a 'conversion' string, the constructor is used as a converteer
if strcmpi(msg,'conversion'),
    h = coeffs;
    return
end

error(msg);

% Normalize coefficients by leading denominator coefficient
[coeffs,msg] = normalizecoeffs(coeffs);
error(msg);

h.version = 1;

h = class(h,'dtf',dfilt(coeffs,connection));
%--------------------------------------------------------------
function [coeffs,msg] = normalizecoeffs(coeffs)
% Normalize coefficients by leading denominator coefficient

msg = '';

for n = 1:length(coeffs),
    section = coeffs{n};
    num = section{1};
    den = section{2};
    try,
        [num,den] = normalizengetord(num,den);
    catch,
        msg = lasterr;
    end
    section = {num,den};
    coeffs{n} = section;
end


% [EOF] - DTF.M


