function [z,nrk] = tzero(D,varargin)
% Computes transmission zeros.

%   Copyright 1986-2019 The MathWorks, Inc.
Ts = D.Ts;

% Set internal delays to zero
if ~isempty(D.Delay.Internal)
   if hasDelayDynamics(D,'zero')
      if Ts==0
         warning(message('Control:analysis:TzeroApproximateDelay1'))
      else
         warning(message('Control:analysis:TzeroApproximateDelay2'))
      end
   end
   D = pade(D,inf,inf,0);
end
   
% Get data and scale
[a,b,c,d,~,e] = getABCDE(D);
if ~D.Scaled
   [a,b,c,e,~,~,info] = ltipack.xscale(a,b,c,d,e,Ts,'Warn',false);
end

if allfinite(d)
   % Compute zeros
   [z,nrk] = ltipack.tzero(a,b,c,d,e,varargin{:});
else
   % Return nothing for systems with NaNs
   z = zeros(0,1);
   nrk = min(size(d));
end

% Warn about (near) singularity
if ~D.Scaled && ~isempty(info.WarnID)
   warning(message(info.WarnID))
end
