function sys = ssequiv_(sys,TL,eL,TR,eR)
%

% Copyright 2023 The MathWorks, Inc.
D = sys.Data_;
for ct=1:numel(D)
   try
      [D(ct),isSingular] = ssequiv(D(ct),TL,eL,TR,eR);
   catch ME
      if isa(sys,'genss')
         if ct>1
            error(message('Control:transformation:ssequiv5',ct))
         else
            error(message('Control:transformation:ssequiv4'))
         end
      else
         if ct>1
            error(message('Control:general:RequiresUniformNumberOfStates','ssequiv'))
         else
            throw(ME)
         end
      end
   end
   if isSingular
      error(message('Control:transformation:ssequiv2'))
   end
end
sys.Data_ = D;