annotate scripts/control/tzero.m @ 3397:1a8e2c0d627a

[project @ 1999-12-18 03:02:18 by jwe]
author jwe
date Sat, 18 Dec 1999 03:02:45 +0000
parents 10f21f7ccc7f
children 0f515bc98460
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3397
1a8e2c0d627a [project @ 1999-12-18 03:02:18 by jwe]
jwe
parents: 3385
diff changeset
1 ## Copyright (C) 1996 Auburn University. All rights reserved.
3381
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
3385
10f21f7ccc7f [project @ 1999-12-15 22:28:26 by jwe]
jwe
parents: 3381
diff changeset
49 function [zer, gain] = tzero (A, B, C, D)
245
16a24e76d6e0 [project @ 1993-12-03 02:00:15 by jwe]
jwe
parents: 73
diff changeset
50
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
51 ## R. Bruce Tenison July 4, 1994
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
52 ## 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
53
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
54 ## 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
55 if(nargin == 4)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
56 Asys = ss2sys(A,B,C,D);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
57 elseif( (nargin == 1) && (! is_struct(A)))
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
58 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
59 elseif(nargin != 1)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
60 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
61 else
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
62 Asys = A;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
63 [A,B,C,D] = sys2ss(Asys);
60
671f8bf989d8 [project @ 1993-08-13 21:03:40 by jwe]
jwe
parents:
diff changeset
64 endif
671f8bf989d8 [project @ 1993-08-13 21:03:40 by jwe]
jwe
parents:
diff changeset
65
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
66 Ao = Asys; # save for leading coefficient
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
67 siso = is_siso(Asys);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
68 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
69
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
70 ## see if it's a gain block
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
71 if(isempty(A))
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
72 zer = [];
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
73 gain = D;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
74 return;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
75 endif
60
671f8bf989d8 [project @ 1993-08-13 21:03:40 by jwe]
jwe
parents:
diff changeset
76
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
77 ## 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
78 ## 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
79
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
80 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
81 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
82 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
83 if(!isempty(A))
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
84 ## repeat with dual system
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
85 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
86
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
87 ## transform back
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
88 [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
89 endif
671f8bf989d8 [project @ 1993-08-13 21:03:40 by jwe]
jwe
parents:
diff changeset
90
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
91 zer = []; # assume none
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
92 [A,B,C,D] = sys2ss(Asys);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
93 if( !isempty(C) )
3238
041ea33fbbf4 [project @ 1999-03-26 17:48:16 by jwe]
jwe
parents: 3236
diff changeset
94 [W,r,Pi] = qr([C, D]');
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
95 [nonz,ztmp] = zgrownorm(r,meps);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
96 if(nonz)
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3346
diff changeset
97 ## We can now solve the generalized eigenvalue problem.
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
98 [pp,mm] = size(D);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
99 nn = rows(A);
3238
041ea33fbbf4 [project @ 1999-03-26 17:48:16 by jwe]
jwe
parents: 3236
diff changeset
100 Afm = [A , B ; C, D] * W';
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
101 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
102
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
103 jdx = (mm+1):(mm+nn);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
104 Af = Afm(1:nn,jdx);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
105 Bf = Bfm(1:nn,jdx);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
106 zer = qz(Af,Bf);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
107 endif
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
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
110 mz = length(zer);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
111 [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
112 ## compute leading coefficient
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
113 if ( (nargout == 2) && siso)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
114 n = rows(A);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
115 if ( mz == n)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
116 gain = D;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
117 elseif ( mz < n )
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
118 gain = C*(A^(n-1-mz))*B;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
119 endif
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
120 else
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
121 gain = [];
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
122 endif
60
671f8bf989d8 [project @ 1993-08-13 21:03:40 by jwe]
jwe
parents:
diff changeset
123 endfunction
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents: 2847
diff changeset
124