function [numc,denc,error_str] = tfchk(num,den)
%TFCHK  Check for proper transfer function.
%   [NUMc,DENc] = TFCHK(NUM,DEN) returns equivalent transfer function
%   numerator and denominator where LENGTH(NUMc) = LENGTH(DENc) if
%   the transfer function NUM,DEN are proper.  Prints an error message
%   if not.
%       A third output returns the error string instead if erroring
%       to the command line.

%   Clay M. Thompson 6-26-90
%   Copyright 1984-2000 The MathWorks, Inc.
%   $Revision: 1.21 $  $Date: 2000/01/31 04:12:20 $

no = nargout;
[nn,mn] = size(num);
[nd,md] = size(den);

% Make sure DEN is a row vector, NUM is assumed to be in rows.
error_str = '';
if nd>1,
   error_str = 'Denominator must be a row vector.';
elseif (mn > md),
   error_str = 'Transfer function not proper.';
end
if ~isempty(error_str) & (no<3),
   error(error_str);
end

% Make NUM and DEN lengths equal.
numc = [zeros(nn,md-mn),num];
denc = den;

% end tfchk
