www.pudn.com > Closid30.rar > Cldn2sys.m, change:1997-06-04,size:1465b


function [s,ns]=cldn2sys(mn,nmn,LeftRight)

% [S,NS]=CLDN2SYS(MN,NMN,LEFTRIGHT)
%                                     
% Given a pair of (left/right) coprime factors in a joint
% system representation, the corresponding system is constructed.
% 
% INPUTS
% MN,NMN:  System representation of the pair of coprime factors 
%          M,N, where MN is the system matrix related to either
%          left:  [M  N],        right: | M |
%                S=inv(M)N              | N |  S=N.inv(M)
%          factorization.
% LEFTRIGHT:  'l' or 'r' indicating the type of factorization.
% 
% OUTPUTS
% S, NS :  System representation of the output result.

% Functions called: clsplit

% 03-11-1990 (originally named cf2ss.m)
% (c) Peter Bongers, Paul Van den Hof
% Mechanical Engineering Systems and Control Group
% Delft University of Technology
% Last update: 03-06-1997.

if (nargin < 3),
  help cldn2sys
  return
end;
  
if (LeftRight == 'r' | LeftRight == 'R' ),
  LeftRight='r';
elseif (LeftRight == 'l' | LeftRight == 'L' ),
  LeftRight='l';
else
  help cldn2sys
  return
end

[a,b,c,d]=clsplit(mn,nmn);
[nout,ninp]=size(d);
if (LeftRight == 'r'),
  nout=nout-ninp;
  cm=c(1:ninp,:);
  cn=c(ninp+1:nout+ninp,:);
  dm=d(1:ninp,:);
  dn=d(ninp+1:nout+ninp,:);
  s = [a-b/dm*cm b/dm;cn-dn/dm*cm dn/dm];
else,
  ninp=ninp-nout;
  bu=b(:,nout+1:nout+ninp);
  du=d(:,nout+1:nout+ninp);
  bv=b(:,1:nout);
  dv=d(:,1:nout);
  s=[a-bv/dv*c bu-bv/dv*du;dv\c dv\du];
end
ns=nmn;