Code covered by the BSD License  

Highlights from
Routh Pade Approximation

Routh Pade Approximation

by

 

To Compute Routh-Pade Approximant of a given stable transfer function to a desired degree.

Gr=Routh_Pade(G,r)
function Gr=Routh_Pade(G,r)

%Function Gr=Routh_Pade(G,r)
%
% Computes the r-th order Routh-Pade Approximation of a given n-th order
% stable transfer function G, with 1<=r<=n. The denominator of the reduced model
% is computed using the  reduced routh/gamma table. The numerator on the
% other hand is computed by moment matching.
%
%
% Example
% G=tf([1 2],[1 3 4 5])
% r=2;
% R=Routh_Pade(G,r)
%
%gives the output
%Transfer function:
%  0.5714 s + 1.143
%---------------------
% s^2 + 2.286 s + 2.857
%
% S. Janardhanan
% janas@ee.iitd.ac.in
%
% Code last updated on 27-Apr-2012

%Error Check
error(nargchk(2,2,nargin));
error(nargoutchk(1,1,nargout));

if ~isa(G,'tf') || ~isscalar(G)
    error('Input needs to be a SISO transfer function');
end
[num,den]=tfdata(G,'v');
D_fact=num(1)/den(1);
num=num-D_fact*den;

den1=den(end:-1:1)/den(1);
n=length(den1)-1;

if ~isreal(r) || (fix(r)~=r) || (r<1) || (r>n)
    error('Invalid value of reduced model order')
end


%Routh Approximation
if mod(n,2)
    A=[den1(1:2:end);den1(2:2:end)];
else
    A=[den1(1:2:end);den1(2:2:end) 0];
end
gam(r)=0;
gam(1)=A(1,1)/A(2,1);
if gam(1)<=0
    disp('System Unstable. Routh Approximation does not exist');
    Gr=0;
    return
end

for i=3:r+1
    for j=1:(size(A,2)-1)
        A(i,j)=A(i-2,j+1)-gam(i-2)*A(i-1,j+1);
    end
    gam(i-1)=A(i-1,1)/A(i,1);
    if gam(i-1)<=0
        disp('System Unstable. Routh Approximation does not exist');
        Gr=0;
        return
    end
end

Q_1=1;
Q_2=[1 gam(1)];

if r==1
    Q=Q_2;
end

for i=3:(r+1)
    Q=conv([1 0 0],Q_1)+[0 gam(i-1)*Q_2];
    Q_1=Q_2;Q_2=Q;
end

P=PadeNum(num,den,Q);

[P,Q]=tfdata(tf(P,Q)+D_fact,'v');
P=P.*(abs(P)>1e-6);
Q=Q.*(abs(Q)>1e-6);
Gr=tf(P,Q)+D_fact;

return

function P=PadeNum(num,den,Q)

num=num(end:-1:1);
r=length(Q)-1;
Ao=zeros(r);
Ar=Ao;
for i=1:r
    Ao(i,1:i)=den(end-i+1:end);
    Ar(i,1:i)=Q(end-i+1:end);
end
P=Ar*inv(Ao)*num(1:r)';
P=P(end:-1:1)';
return

Contact us