function [num,den,Ts,Td] = tfdata(sys,flag)
%TFDATA  Quick access to transfer function data.
%
%   [NUM,DEN] = TFDATA(SYS)  returns the numerator(s) and denominator(s) 
%   of the transfer function SYS.  NUM and DEN are cell arrays with as
%   many rows as outputs and as many columns as inputs, and their (I,J)
%   entries specify the transfer function from input J to output I. 
%   SYS is first converted to transfer function if necessary.
%
%   [NUM,DEN,TS,TD] = TFDATA(SYS)  also returns the sample time TS and
%   input delays TD.  For continuous systems, TD is a vector with one 
%   entry per input channel.  For discrete systems, TD is the empty 
%   matrix [].
%
%   For SISO systems, the convenience syntax
%       [NUM,DEN] = TFDATA(SYS,'v')
%   returns the numerator and denominator as row vectors rather than
%   cell arrays.
%
%   Other properties of SYS can be accessed with GET or by direct 
%   structure-like referencing (e.g., SYS.Ts)
%
%   See also  GET, SSDATA, ZPKDATA.

%       Author(s): P. Gahinet, 25-3-96
%       Copyright (c) 1986-97 by The MathWorks, Inc.
%       $Revision: 1.7 $   $Date: 1997/04/09 00:30:09 $


sys = tf(sys);   % default method for TF children
num = sys.num;
den = sys.den;

% Convenience syntax for SISO case
s = size(num);
if nargin>1 & prod(s)<=1,
   if any(s),
      num = num{1};
      den = den{1};
   else
      num = zeros(1,0);
      den = zeros(1,0);
   end
end

if nargout > 2,
   L = struct(sys.lti);  % LTI structure
   Ts = L.Ts;
   Td = L.Td;
end

% end ../@tf/tfdata.m
