annotate scripts/control/tzero.m @ 3385:10f21f7ccc7f

[project @ 1999-12-15 22:28:26 by jwe]
author jwe
date Wed, 15 Dec 1999 22:28:52 +0000
parents 69b167451491
children 1a8e2c0d627a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
1 ## Copyright (C) 1996 Auburn University. All Rights Reserved
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
2 ##
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
3 ## This file is part of Octave.
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
4 ##
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
6 ## under the terms of the GNU General Public License as published by the
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
7 ## Free Software Foundation; either version 2, or (at your option) any
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
8 ## later version.
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
9 ##
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but WITHOUT
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
11 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
12 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
13 ## for more details.
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
14 ##
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
15 ## You should have received a copy of the GNU General Public License
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
16 ## along with Octave; see the file COPYING. If not, write to the Free
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
17 ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
18
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
19 ## -*- texinfo -*-
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
20 ## @deftypefn {Function File} {} tzero (@var{a}, @var{b}, @var{c}, @var{d}@{, @var{opt}@})
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
21 ## @deftypefnx {Function File} {} tzero (@var{sys}@{,@var{opt}@})
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
22 ## Compute transmission zeros of a continuous
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
23 ## @example
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
24 ## .
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
25 ## x = Ax + Bu
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
26 ## y = Cx + Du
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
27 ## @end example
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
28 ## or discrete
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
29 ## @example
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
30 ## x(k+1) = A x(k) + B u(k)
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
31 ## y(k) = C x(k) + D u(k)
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
32 ## @end example
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
33 ## system.
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
34 ## @strong{Outputs}
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
35 ## @table @var
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
36 ## @item zer
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
37 ## transmission zeros of the system
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
38 ## @item gain
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
39 ## leading coefficient (pole-zero form) of SISO transfer function
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
40 ## returns gain=0 if system is multivariable
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
41 ## @end table
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
42 ## @strong{References}
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
43 ## @enumerate
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
44 ## @item Emami-Naeini and Van Dooren, Automatica, 1982.
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
45 ## @item Hodel, "Computation of Zeros with Balancing," 1992 Lin. Alg. Appl.
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
46 ## @end enumerate
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
47 ## @end deftypefn
3346
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
48
8dd4718801fd [project @ 1999-11-09 18:18:12 by jwe]
jwe
parents: 3284
diff changeset
49
3385
10f21f7ccc7f [project @ 1999-12-15 22:28:26 by jwe]
jwe
parents: 3381
diff changeset
50 function [zer, gain] = tzero (A, B, C, D)
245
16a24e76d6e0 [project @ 1993-12-03 02:00:15 by jwe]
jwe
parents: 73
diff changeset
51
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
52 ## R. Bruce Tenison July 4, 1994
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
53 ## A. S. Hodel Aug 1995: allow for MIMO and system data structures
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
54
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
55 ## get A,B,C,D and Asys variables, regardless of initial form
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
56 if(nargin == 4)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
57 Asys = ss2sys(A,B,C,D);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
58 elseif( (nargin == 1) && (! is_struct(A)))
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
59 usage("[zer,gain] = tzero(A,B,C,D) or zer = tzero(Asys)");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
60 elseif(nargin != 1)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
61 usage("[zer,gain] = tzero(A,B,C,D) or zer = tzero(Asys)");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
62 else
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
63 Asys = A;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
64 [A,B,C,D] = sys2ss(Asys);
60
671f8bf989d8 [project @ 1993-08-13 21:03:40 by jwe]
jwe
parents:
diff changeset
65 endif
671f8bf989d8 [project @ 1993-08-13 21:03:40 by jwe]
jwe
parents:
diff changeset
66
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
67 Ao = Asys; # save for leading coefficient
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
68 siso = is_siso(Asys);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
69 digital = is_digital(Asys); # check if it's mixed or not
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
70
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
71 ## see if it's a gain block
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
72 if(isempty(A))
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
73 zer = [];
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
74 gain = D;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
75 return;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
76 endif
60
671f8bf989d8 [project @ 1993-08-13 21:03:40 by jwe]
jwe
parents:
diff changeset
77
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
78 ## First, balance the system via the zero computation generalized eigenvalue
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
79 ## problem balancing method (Hodel and Tiller, Linear Alg. Appl., 1992)
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
80
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
81 Asys = zgpbal(Asys); [A,B,C,D] = sys2ss(Asys); # balance coefficients
3238
041ea33fbbf4 [project @ 1999-03-26 17:48:16 by jwe]
jwe
parents: 3236
diff changeset
82 meps = 2*eps*norm([A, B; C, D],'fro');
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
83 Asys = zgreduce(Asys,meps); [A, B, C, D] = sys2ss(Asys); # ENVD algorithm
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
84 if(!isempty(A))
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
85 ## repeat with dual system
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
86 Asys = ss2sys(A', C', B', D'); Asys = zgreduce(Asys,meps);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
87
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
88 ## transform back
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
89 [A,B,C,D] = sys2ss(Asys); Asys = ss2sys(A', C', B', D');
60
671f8bf989d8 [project @ 1993-08-13 21:03:40 by jwe]
jwe
parents:
diff changeset
90 endif
671f8bf989d8 [project @ 1993-08-13 21:03:40 by jwe]
jwe
parents:
diff changeset
91
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
92 zer = []; # assume none
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
93 [A,B,C,D] = sys2ss(Asys);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
94 if( !isempty(C) )
3238
041ea33fbbf4 [project @ 1999-03-26 17:48:16 by jwe]
jwe
parents: 3236
diff changeset
95 [W,r,Pi] = qr([C, D]');
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
96 [nonz,ztmp] = zgrownorm(r,meps);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
97 if(nonz)
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
98 ## We can now solve the generalized eigenvalue problem.
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
99 [pp,mm] = size(D);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
100 nn = rows(A);
3238
041ea33fbbf4 [project @ 1999-03-26 17:48:16 by jwe]
jwe
parents: 3236
diff changeset
101 Afm = [A , B ; C, D] * W';
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
102 Bfm = [eye(nn), zeros(nn,mm); zeros(pp,nn+mm)]*W';
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
103
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
104 jdx = (mm+1):(mm+nn);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
105 Af = Afm(1:nn,jdx);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
106 Bf = Bfm(1:nn,jdx);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
107 zer = qz(Af,Bf);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
108 endif
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
109 endif
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
110
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
111 mz = length(zer);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
112 [A,B,C,D] = sys2ss(Ao); # recover original system
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
113 ## compute leading coefficient
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
114 if ( (nargout == 2) && siso)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
115 n = rows(A);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
116 if ( mz == n)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
117 gain = D;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
118 elseif ( mz < n )
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
119 gain = C*(A^(n-1-mz))*B;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
120 endif
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
121 else
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
122 gain = [];
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
123 endif
60
671f8bf989d8 [project @ 1993-08-13 21:03:40 by jwe]
jwe
parents:
diff changeset
124 endfunction
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
125