function [num,den] = utTrimNumDen(num,den,RightTrim)
% Trims extra leading/trailing zeros in numerator and denominator vectors.
%
% Assuming NUM,DEN have equal length and are not both identically zero, 
% this function 
%   * Eliminates leading zero entries appearing in both NUM and DEN
%   * Also eliminates trailing zeros when RIGHTTRIM=TRUE.
%
% On exit, NUM(1) or DEN(1) is always nonzero.
%
% STATIC METHOD.

%   Copyright 1986-2012 The MathWorks, Inc.
if RightTrim
   % Trim both leading and trailing zeros
   for ct=1:numel(num)
      i = find(num{ct}~=0 | den{ct}~=0);
      num{ct} = num{ct}(i(1):i(end));
      den{ct} = den{ct}(i(1):i(end));
   end
else
   % Only trim leading zeros
   for ct=1:numel(num)
      i = find(num{ct}~=0 | den{ct}~=0);
      if i(1)>1
         num{ct}(1:i(1)-1) = [];
         den{ct}(1:i(1)-1) = [];
      end
   end
end