]> Creatis software - CreaPhase.git/blob - octave_packages/control-2.3.52/@lti/zero.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / control-2.3.52 / @lti / zero.m
1 ## Copyright (C) 2009, 2011   Lukas F. Reichlin
2 ##
3 ## This file is part of LTI Syncope.
4 ##
5 ## LTI Syncope is free software: you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation, either version 3 of the License, or
8 ## (at your option) any later version.
9 ##
10 ## LTI Syncope is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 ## GNU General Public License for more details.
14 ##
15 ## You should have received a copy of the GNU General Public License
16 ## along with LTI Syncope.  If not, see <http://www.gnu.org/licenses/>.
17
18 ## -*- texinfo -*-
19 ## @deftypefn {Function File} {@var{z} =} zero (@var{sys})
20 ## @deftypefnx {Function File} {[@var{z}, @var{k}] =} zero (@var{sys})
21 ## Compute transmission zeros and gain of LTI model.
22 ##
23 ## @strong{Inputs}
24 ## @table @var
25 ## @item sys
26 ## LTI model.
27 ## @end table
28 ##
29 ## @strong{Outputs}
30 ## @table @var
31 ## @item z
32 ## Transmission zeros of @var{sys}.
33 ## @item k
34 ## Gain of @var{sys}.
35 ## @end table
36 ## @end deftypefn
37
38 ## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
39 ## Created: October 2009
40 ## Version: 0.2
41
42 function [zer, gain] = zero (sys)
43
44   if (nargin > 1)
45     print_usage ();
46   endif
47
48   [zer, gain] = __zero__ (sys, nargout);
49
50 endfunction
51
52
53 ## transmission zeros of state-space models
54 ##
55 ## Results from the "Dark Side" 7.5 and 7.8
56 ##
57 ##  -13.2759
58 ##   12.5774
59 ##  -0.0155
60 ##
61 ## Results from Scilab 5.2.0b1 (trzeros)
62 ##
63 ##  - 13.275931  
64 ##    12.577369  
65 ##  - 0.0155265
66 ##
67 %!shared z, z_exp
68 %! A = [   -0.7   -0.0458     -12.2        0
69 %!            0    -0.014   -0.2904   -0.562
70 %!            1   -0.0057      -1.4        0
71 %!            1         0         0        0 ];
72 %!
73 %! B = [  -19.1      -3.1
74 %!      -0.0119   -0.0096
75 %!        -0.14     -0.72
76 %!            0         0 ];
77 %!
78 %! C = [      0         0        -1        1
79 %!            0         0     0.733        0 ];
80 %!
81 %! D = [      0         0
82 %!       0.0768    0.1134 ];
83 %!
84 %! sys = ss (A, B, C, D, "scaled", true);
85 %! z = sort (zero (sys));
86 %!
87 %! z_exp = sort ([-13.2759; 12.5774; -0.0155]);
88 %!
89 %!assert (z, z_exp, 1e-4);
90
91
92 ## transmission zeros of descriptor state-space models
93 %!shared z, z_exp
94 %! A = [  1     0     0     0     0     0     0     0     0
95 %!        0     1     0     0     0     0     0     0     0
96 %!        0     0     1     0     0     0     0     0     0
97 %!        0     0     0     1     0     0     0     0     0
98 %!        0     0     0     0     1     0     0     0     0
99 %!        0     0     0     0     0     1     0     0     0
100 %!        0     0     0     0     0     0     1     0     0
101 %!        0     0     0     0     0     0     0     1     0
102 %!        0     0     0     0     0     0     0     0     1 ];
103 %!
104 %! E = [  0     0     0     0     0     0     0     0     0
105 %!        1     0     0     0     0     0     0     0     0
106 %!        0     1     0     0     0     0     0     0     0
107 %!        0     0     0     0     0     0     0     0     0
108 %!        0     0     0     1     0     0     0     0     0
109 %!        0     0     0     0     1     0     0     0     0
110 %!        0     0     0     0     0     0     0     0     0
111 %!        0     0     0     0     0     0     1     0     0
112 %!        0     0     0     0     0     0     0     1     0 ];
113 %!
114 %! B = [ -1     0     0
115 %!        0     0     0
116 %!        0     0     0
117 %!        0    -1     0
118 %!        0     0     0
119 %!        0     0     0
120 %!        0     0    -1
121 %!        0     0     0
122 %!        0     0     0 ];
123 %!
124 %! C = [  0     1     1     0     3     4     0     0     2
125 %!        0     1     0     0     4     0     0     2     0
126 %!        0     0     1     0    -1     4     0    -2     2 ];
127 %!
128 %! D = [  1     2    -2
129 %!        0    -1    -2
130 %!        0     0     0 ];
131 %!
132 %! sys = dss (A, B, C, D, E, "scaled", true);
133 %! z = zero (sys);
134 %!
135 %! z_exp = 1;
136 %!
137 %!assert (z, z_exp, 1e-4);
138
139
140 ## Gain of descriptor state-space models
141 %!shared p, pi, z, zi, k, ki, p_tf, pi_tf, z_tf, zi_tf, k_tf, ki_tf
142 %! P = ss (-2, 3, 4, 5);
143 %! Pi = inv (P);
144 %!
145 %! p = pole (P);
146 %! [z, k] = zero (P);
147 %!
148 %! pi = pole (Pi);
149 %! [zi, ki] = zero (Pi);
150 %!
151 %! P_tf = tf (P);
152 %! Pi_tf = tf (Pi);
153 %!
154 %! p_tf = pole (P_tf);
155 %! [z_tf, k_tf] = zero (P_tf);
156 %!
157 %! pi_tf = pole (Pi_tf);
158 %! [zi_tf, ki_tf] = zero (Pi_tf);
159 %!
160 %!assert (p, zi, 1e-4);
161 %!assert (z, pi, 1e-4);
162 %!assert (k, inv (ki), 1e-4);
163 %!assert (p_tf, zi_tf, 1e-4);
164 %!assert (z_tf, pi_tf, 1e-4);
165 %!assert (k_tf, inv (ki_tf), 1e-4);