function [num,den,N,M] = normalizeNgetord(num,den)
%NORMALIZE_GETORD   Normalize the transfer function and get
%                   num and den order.

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

% Remove trailing zeros
nindx = max(find(num ~= 0));
mindx = max(find(den ~= 0));

if ~isempty(nindx),
    num = num(1:nindx);
end

if ~isempty(mindx),
    den = den(1:mindx);
end

if den(1) == 0,
    error('The leading coefficient of the denominator cannot be zero.');
end

% Make sure num and den are row vectors and normalize by the
% leading coeff. of den
num = num(:).'./den(1);
den = den(:).'./den(1);

% Gather the order of num and den
N = length(num) - 1;
M = length(den) - 1;
