function check_model(sys)
% CHECK_MODEL  Checks LTI models for compatibility with the SIMC model
% reduction and PID tuning rules.
%
% CHECK_MODEL(SYS) checks the LTI model SYS.
%
% SIMC model reduction and PID tuning can only be applied to systems with:
%   No unstable poles (excluding integrating systems)
%   No oscillatory (complex) poles or zeros

% Author(s): Bora Eryilmaz, The MathWorks, Inc.

[Z,P] = zpkdata(sys, 'v');

if any(P > 0)
  error('Unstable processes (with the exception of integrating systems) cannot be handled by the SIMC tuning method.')
elseif ~isreal(P) || ~isreal(Z)
  error('Oscillating processes (with complex poles or zeros) cannot be handled by the SIMC tuning method.')
end
end
