3432
|
1 ## Copyright (C) 1996 Auburn University. All rights reserved. |
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by the |
|
7 ## Free Software Foundation; either version 2, or (at your option) any |
|
8 ## later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but WITHOUT |
|
11 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 ## for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301 USA. |
3432
|
19 |
3451
|
20 ## -*- texinfo -*- |
5016
|
21 ## @deftypefn {Function File} {[@var{zer}, @var{gain}] =} tzero (@var{a}, @var{b}, @var{c}, @var{d}, @var{opt}) |
|
22 ## @deftypefnx {Function File} {[@var{zer}, @var{gain}] =} tzero (@var{sys}, @var{opt}) |
|
23 ## Compute transmission zeros of a continuous system: |
|
24 ## @iftex |
|
25 ## @tex |
|
26 ## $$ \dot x = Ax + Bu $$ |
|
27 ## $$ y = Cx + Du $$ |
|
28 ## @end tex |
|
29 ## @end iftex |
|
30 ## @ifinfo |
3432
|
31 ## @example |
|
32 ## . |
|
33 ## x = Ax + Bu |
|
34 ## y = Cx + Du |
|
35 ## @end example |
5016
|
36 ## @end ifinfo |
|
37 ## or of a discrete one: |
|
38 ## @iftex |
|
39 ## @tex |
|
40 ## $$ x_{k+1} = Ax_k + Bu_k $$ |
|
41 ## $$ y_k = Cx_k + Du_k $$ |
|
42 ## @end tex |
|
43 ## @end iftex |
|
44 ## @ifinfo |
3432
|
45 ## @example |
|
46 ## x(k+1) = A x(k) + B u(k) |
|
47 ## y(k) = C x(k) + D u(k) |
|
48 ## @end example |
5016
|
49 ## @end ifinfo |
|
50 ## |
3432
|
51 ## @strong{Outputs} |
|
52 ## @table @var |
|
53 ## @item zer |
|
54 ## transmission zeros of the system |
|
55 ## @item gain |
5016
|
56 ## leading coefficient (pole-zero form) of @acronym{SISO} transfer function |
3432
|
57 ## returns gain=0 if system is multivariable |
|
58 ## @end table |
|
59 ## @strong{References} |
|
60 ## @enumerate |
|
61 ## @item Emami-Naeini and Van Dooren, Automatica, 1982. |
5016
|
62 ## @item Hodel, @cite{Computation of Zeros with Balancing}, 1992 Lin. Alg. Appl. |
3432
|
63 ## @end enumerate |
|
64 ## @end deftypefn |
|
65 |
|
66 ## Author: R. Bruce Tenison <btenison@eng.auburn.edu> |
|
67 ## Created: July 4, 1994 |
|
68 ## A. S. Hodel Aug 1995: allow for MIMO and system data structures |
|
69 |
|
70 function [zer, gain] = tzero (A, B, C, D) |
|
71 |
|
72 ## get A,B,C,D and Asys variables, regardless of initial form |
|
73 if(nargin == 4) |
4771
|
74 Asys = ss(A,B,C,D); |
4030
|
75 elseif( (nargin == 1) && (! isstruct(A))) |
6046
|
76 print_usage (); |
3432
|
77 elseif(nargin != 1) |
6046
|
78 print_usage (); |
3432
|
79 else |
|
80 Asys = A; |
|
81 [A,B,C,D] = sys2ss(Asys); |
|
82 endif |
|
83 |
|
84 Ao = Asys; # save for leading coefficient |
|
85 siso = is_siso(Asys); |
|
86 digital = is_digital(Asys); # check if it's mixed or not |
|
87 |
|
88 ## see if it's a gain block |
|
89 if(isempty(A)) |
|
90 zer = []; |
|
91 gain = D; |
|
92 return; |
|
93 endif |
|
94 |
|
95 ## First, balance the system via the zero computation generalized eigenvalue |
|
96 ## problem balancing method (Hodel and Tiller, Linear Alg. Appl., 1992) |
|
97 |
3438
|
98 Asys = __zgpbal__ (Asys); [A,B,C,D] = sys2ss(Asys); # balance coefficients |
3432
|
99 meps = 2*eps*norm ([A, B; C, D], "fro"); |
|
100 Asys = zgreduce(Asys,meps); [A, B, C, D] = sys2ss(Asys); # ENVD algorithm |
|
101 if(!isempty(A)) |
|
102 ## repeat with dual system |
4771
|
103 Asys = ss(A', C', B', D'); Asys = zgreduce(Asys,meps); |
3432
|
104 |
|
105 ## transform back |
4771
|
106 [A,B,C,D] = sys2ss(Asys); Asys = ss(A', C', B', D'); |
3432
|
107 endif |
|
108 |
|
109 zer = []; # assume none |
|
110 [A,B,C,D] = sys2ss(Asys); |
|
111 if( !isempty(C) ) |
|
112 [W,r,Pi] = qr([C, D]'); |
|
113 [nonz,ztmp] = zgrownorm(r,meps); |
|
114 if(nonz) |
|
115 ## We can now solve the generalized eigenvalue problem. |
|
116 [pp,mm] = size(D); |
|
117 nn = rows(A); |
|
118 Afm = [A , B ; C, D] * W'; |
|
119 Bfm = [eye(nn), zeros(nn,mm); zeros(pp,nn+mm)]*W'; |
|
120 |
|
121 jdx = (mm+1):(mm+nn); |
|
122 Af = Afm(1:nn,jdx); |
|
123 Bf = Bfm(1:nn,jdx); |
|
124 zer = qz(Af,Bf); |
|
125 endif |
|
126 endif |
|
127 |
|
128 mz = length(zer); |
|
129 [A,B,C,D] = sys2ss(Ao); # recover original system |
|
130 ## compute leading coefficient |
|
131 if ( (nargout == 2) && siso) |
|
132 n = rows(A); |
|
133 if ( mz == n) |
|
134 gain = D; |
|
135 elseif ( mz < n ) |
|
136 gain = C*(A^(n-1-mz))*B; |
|
137 endif |
|
138 else |
|
139 gain = []; |
|
140 endif |
|
141 endfunction |
|
142 |