-
Notifications
You must be signed in to change notification settings - Fork 0
/
btabal_cf.m
109 lines (99 loc) · 4.14 KB
/
btabal_cf.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
function [sysr,hsv] = btabal_cf(fact,sys,tol,ord,alpha)
%BTABAL_CF Balance and truncate approximation of coprime factors
% with balancing.
% [SYSR,HSV] = BTABAL_CF(FACT,SYS,TOL,ORD,ALPHA) calculates for
% the transfer function
% -1
% G(lambda) = C(lambdaI-A) B + D
%
% of an original system SYS = (A,B,C,D) an approximate
% transfer function
% -1
% Gr(lambda) = Cr(lambdaI-Ar) Br + Dr
%
% of a reduced order system SYSR = (Ar,Br,Cr,Dr) using the
% Balance & Truncate approximation method with balancing
% on a Left/Right Coprime Factorization (LCF/RCF) of G.
% The allowed factorizations are:
% FACT = 'rcfid' - RCF with inner denominator
% FACT = 'lcfid' - LCF with inner denominator
% FACT = 'rcfs' - RCF with prescribed stability degree ALPHA
% FACT = 'lcfs' - LCF with prescribed stability degree ALPHA
% FACT = ' ' - no coprime factorization is used
%
% TOL is a tolerance vector [TOL1, TOL2, TOL3], where TOL1 is the
% tolerance for model reduction and TOL3 is the tolerance
% for controlability/observability tests for computing right/left
% coprime factorizations. TOL2 is not used.
%
% ORD specifies the desired order of the reduced system SYSR.
%
% ALPHA is the stability degree for the eigenvalues of A when
% using the RCF or LCF with prescribed stability degree.
% For a continuous-time system ALPHA <= 0 is the maximum value
% for the real parts of eigenvalues (default: -0.05), while for
% a discrete-time system, 1 >= ALPHA >= 0 represents the maximum
% value for the moduli of eigenvalues (default: 0.95).
%
% HSV contains the decreasingly ordered Hankel singular values of
% the extended system (see Method with 'type btabal_cf').
%
% The order NR of the reduced system SYSR is determined as follows:
% let NMIN be the order of a minimal realization of the extended
% system (see Method with 'type btabal_cf'). Then
% (1) if TOL1 > 0 and ORD < 0, then NR = min(NRS,NMIN), where
% NRS is the number of Hankel singular values greater than TOL1;
% (2) if ORD >= 0, then NR = MIN(ORD,NMIN).
%
% Method:
% The following approach is used in conjunction with either
% a stable Left Coprime Factorization (LCF) or a stable
% Right Coprime Factorization (RCF) of G:
%
% 1. Compute the appropriate stable coprime factorization of G:
% -1 -1
% G = R *Q (LCF) or G = Q*R (RCF).
%
% 2. Perform the Balance and Truncate model reduction algorithm,
% with balancing, on the extended system
% ( Q )
% Ge = ( Q R ) (LCF) or Ge = ( R ) (RCF)
%
% to obtain a reduced extended system with reduced factors
% ( Qr )
% Ger = ( Qr Rr ) (LCF) or Ger = ( Rr ) (RCF).
%
% 3. Recover the reduced system from the reduced factors as
% -1 -1
% Gr = Rr *Qr (LCF) or Gr = Qr*Rr (RCF).
%
% RELEASE 2.0 of SLICOT Model and Controller Reduction Toolbox.
% Based on SLICOT RELEASE 5.7, Copyright (c) 2002-2020 NICONET e.V.
%
% Interface M-function to the SLICOT-based MEX-function SYSRED.
% A. Varga 07-30-1998. Revised 02-16-1999.
% Revised, V. Sima 12-01-2002.
%
if ~isa(sys,'lti')
error('The input system SYS must be an LTI object')
end
ni = nargin;
discr = double(sys.ts > 0);
if ni < 5
alpha = -0.05;
if discr
alpha = 1 + alpha;
end
end
if ni < 4
ord = -1;
end
if ni < 3
tol = 0;
end
k = find(strcmp({'rcfid','lcfid','rcfs','lcfs'},fact)==1);
if isempty(k), k = 0; end
[a,b,c,d]=ssdata(sys);
[ar,br,cr,dr,hsv]=sysred(10*k+1,a,b,c,d,tol,discr,ord,alpha);
sysr = ss(ar,br,cr,dr,sys);
% end btabal_cf