%
%
%   Function SMINREAL is uses minreal to obtain a minimal realization.
%
%   See: MINREAL
%

function Gm = sminreal(G, tol)

   if nargin < 2
      tol = 1e-12;
   end

   [A,B,C,D] = unpck(G);
   
   [Am,Bm,Cm,Dm] = minreal(A, B, C, D, tol);
   Gm = pck(Am,Bm,Cm,Dm);
   if isempty(Gm)
      Gm = G;
   end
end
