function [S,R]=routh(Z,tol,discrete,sw);
%
% [S,R]=routh(Z,tol,discrete,sw);
%
%	Routh stability test. 
%
%   Determines conditions on parameter k such that the polynomial
%       P(s,k)=a_n(k)s^k+...+a_0(k) is Hurwitz,
%	where a_i(k) may be polyn. or rational functions of k,
%	expressed in one of the following formats:
%	1) Z={{[num_n] [den_n]}, ..., {[num_0] [den_0]}}
%		:most generic case: polinomial with rational coefficients.
%	2) Z={[num] [den]} where num,den express the open loop
%		transfer function. In this case the routh test
%		is performed on the polynomial P(s,k)=den+k*num
%	3) Polynomial dependence of the coefficients:
%		Z=[a_n; a_n-1; ...; a_0]
%		where a_i are polynomials in k.
%   4) Z= tf object. Functioning is similar to 2)
%
%	If 'discrete' == 1 performs Jury stability test
%	for discrete-time polynomials. Uses bilinear
%	mapping. only options 2) 3) 4) work for discrete time.
%
%  If 'sw'==1 displays first column of routh array.
%  If 'sw'==2 displays all routh table.
%  Needed .m files: polysum, polysign, ratsimpl, clzero
%
%		@ G. Calafiore 1999 (revised 2005)
%

% CODE in ROUTH.p
