function [boo,MsgID] = isstable(D,tol)
% Returns 0 for stable, 1 for unstable, and NaN for "don't know"

%   Copyright 1986-2010 The MathWorks, Inc.
if nargin==1
   tol = 0;
end
MsgID = '';
% Compute poles
p = pole(D,'fast');
% Test for stability
if D.Ts==0
   boo = all(real(p)<-tol*(1+abs(p)));
else
   boo = all(abs(p)<1-tol);
end
boo = double(boo);
