www.pudn.com > Closid30.rar > CLDNCF.M, change:1998-05-19,size:2760b


function [DN,n]=cldncf(s,ns,option) 
 
% [DN,n] = cldncf(s,ns,option) 
% 
% Computation of discrete normalized (right or left) coprime 
% factorization.  
% 
% INPUTS: 
% s      : system representation of the transfer function S. 
% ns     : state-space dimension of s. 
% option = 'R' for normalized right coprime factorization: 
%              S = N*inv(D) with N~N + D~D = I, D~(z) := D^T(1/z); 
%        = 'L' for normalized left coprime factorization: 
%              S = inv(D)*N with NN~ + DD~ = I, D~(z) := D^T(1/z); 
% OUTPUTS: 
% DN     : system representation of the normalized coprime factorization 
%          in DN-format, i.e. it is given by 
%          [D N] if option='L' , [D^T N^T]^T if option='R' 
% n      : state space dimension of DN. 
% 
% METHOD: Bongers, P.M.M., P.S.C. Heuberger (1990), Discrete Normalized 
%         Coprime Factorization, Proc. 9-th INRIA Conf. Analysis and 
%         Optimization of Systems, Antibes, Franc. Also in Lecture Notes 
%         in Control and Information Sciences, vol. 144, pp. 307-313, 1990 
 
%************************************************************************** 
% 
% (c) P.M.J. Van den Hof, november 1996. 
% Mechanical Engineering Systems and Control Group 
% Delft University of Technology 
 
% file         : cldncf.m 
% info         : This file is based on the routines dncf.m and dncf2.m 
%                originally written by P.M.M. Bongers, october 1990, and  
%                modified by R.A. de Callafon, march 1995. 
% functions    : clsplit, cldare, chol 
% last update  : 19-05-1998, Paul Van den Hof 
 
%**************************************************************************** 
if nargin~=3, 
  error('Number of input arguments is not correct'); 
end; 
   
lncf='f';   
if length(option) == 1, 
    if (option == 'r' | option == 'R'), 
        lncf='r'; 
    elseif ((option == 'l') | (option =='L')), 
        lncf='l'; 
    end; 
end; 
 
if (lncf == 'f'),   
  error('incorrect option, can only be ''L'' or ''R'''); 
end 
 
if (lncf=='r'), 
    s=s';  % simply transpose the system and compute the NLCF 
end; 
   
x=0; 
[a,b,c,d]=clsplit(s,ns); 
[nout,ninp]=size(d); 
if max(abs(d))>=100*eps,pard=1;else,pard=0;end; 
if (pard==1), 
    a2=[a b;0*ones(ninp,ns+ninp)]; 
    b2=[0*b;eye(ninp)]; 
    c2=[c d]; 
    h=diag([zeros(1,ns) ones(1,ninp)]); 
else, 
    a2=a;c2=c;b2=b;h=b*b'; 
end; 
r=eye(nout); 
n2=length(a2); 
if (rank(a2)==n2), 
    optionr='SCH'; 
else 
    optionr='GEV'; 
end; 
p=cldare(a2',c2',r,h,optionr); 
f=a2*p*c2'*inv(c2*p*c2' + eye(nout)); 
h=chol(inv(c2*p*c2' + eye(nout))); % <-- Cholesky decomposition for H 
if (pard==1), 
    f=[eye(ns) 0*ones(ns,ninp)]*f; 
end; 
DN=[a-f*c -f b-f*d ;h*c h h*d]; 
n=ns; 
if (lncf=='r'), 
    DN=DN'; 
end;