% function sys = nd2sys(num,den,gain)
%
%   ND2SYS converts a numerator/denominator single-input/
%   single-output transfer function into a SYSTEM matrix. 
%   GAIN is an optional argument that scales the output SYS.
%
%   See also:  PCK, PSS2SYS, SYS2PSS, TF2SS, UNPCK, SYSIC, and ZP2SYS.

function sys = nd2sys(num,den,gain)
  if nargin < 2
    disp('usage: sys = nd2sys(num,den,gain)');
    return
  end
  if length(num) > length(den)
    error('numerator order is larger than denominator order');
    return
  else
    if nargin == 2
      [a,b,c,d] = tf2ss(num,den);
      sys = pck(a,b,c,d);
    else
      [a,b,c,d] = tf2ss(num,den);
      sys = pck(a,b,c,d);
      sys = mscl(sys,gain); 
    end
  end
%
% Copyright MUSYN INC 1991,  All Rights Reserved
