|
1 | | -# -*- coding: utf-8 -*- |
2 | | -""" |
3 | | -The :mod:`control.matlab` module contains a number of functions that emulate |
4 | | -some of the functionality of MATLAB. The intent of these functions is to |
5 | | -provide a simple interface to the python control systems library |
6 | | -(python-control) for people who are familiar with the MATLAB Control Systems |
7 | | -Toolbox (tm). |
8 | | -""" |
9 | | - |
10 | | -"""Copyright (c) 2009 by California Institute of Technology |
11 | | -All rights reserved. |
12 | | -
|
13 | | -Copyright (c) 2011 by Eike Welk |
14 | | -
|
15 | | -
|
16 | | -Redistribution and use in source and binary forms, with or without |
17 | | -modification, are permitted provided that the following conditions |
18 | | -are met: |
19 | | -
|
20 | | -1. Redistributions of source code must retain the above copyright |
21 | | - notice, this list of conditions and the following disclaimer. |
22 | | -
|
23 | | -2. Redistributions in binary form must reproduce the above copyright |
24 | | - notice, this list of conditions and the following disclaimer in the |
25 | | - documentation and/or other materials provided with the distribution. |
| 1 | +# Original author: Richard M. Murray |
| 2 | +# Creation date: 29 May 09 |
| 3 | +# Pre-2014 revisions: Kevin K. Chen, Dec 2010 |
26 | 4 |
|
27 | | -3. Neither the name of the California Institute of Technology nor |
28 | | - the names of its contributors may be used to endorse or promote |
29 | | - products derived from this software without specific prior |
30 | | - written permission. |
| 5 | +"""MATLAB compatibility sub-package. |
31 | 6 |
|
32 | | -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
33 | | -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
34 | | -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
35 | | -FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CALTECH |
36 | | -OR THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
37 | | -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
38 | | -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
39 | | -USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
40 | | -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
41 | | -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
42 | | -OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
43 | | -SUCH DAMAGE. |
44 | | -
|
45 | | -Author: Richard M. Murray |
46 | | -Date: 29 May 09 |
47 | | -Revised: Kevin K. Chen, Dec 10 |
48 | | -
|
49 | | -$Id$ |
| 7 | +The :mod:`control.matlab` sub-package contains a number of functions |
| 8 | +that emulate some of the functionality of MATLAB. The intent of these |
| 9 | +functions is to provide a simple interface to the python control |
| 10 | +systems library (python-control) for people who are familiar with the |
| 11 | +MATLAB Control Systems Toolbox (tm). |
50 | 12 |
|
51 | 13 | """ |
52 | 14 |
|
|
101 | 63 | # Set up defaults corresponding to MATLAB conventions |
102 | 64 | from ..config import * |
103 | 65 | use_matlab_defaults() |
104 | | - |
105 | | -r""" |
106 | | -The following tables give an overview of the module ``control.matlab``. |
107 | | -They also show the implementation progress and the planned features of the |
108 | | -module. |
109 | | -
|
110 | | -The symbols in the first column show the current state of a feature: |
111 | | -
|
112 | | -* ``*`` : The feature is currently implemented. |
113 | | -* ``-`` : The feature is not planned for implementation. |
114 | | -* ``s`` : A similar feature from another library (Scipy) is imported into |
115 | | - the module, until the feature is implemented here. |
116 | | -
|
117 | | -
|
118 | | -Creating linear models |
119 | | ----------------------------------------------------------------------------- |
120 | | -
|
121 | | -== ========================== ============================================ |
122 | | -\* :func:`tf` create transfer function (TF) models |
123 | | -\* :func:`zpk` create zero/pole/gain (ZPK) models. |
124 | | -\* :func:`ss` create state-space (SS) models |
125 | | -\ dss create descriptor state-space models |
126 | | -\ delayss create state-space models with delayed terms |
127 | | -\* :func:`frd` create frequency response data (FRD) models |
128 | | -\ lti/exp create pure continuous-time delays (TF and |
129 | | - ZPK only) |
130 | | -\ filt specify digital filters |
131 | | -\- lti/set set/modify properties of LTI models |
132 | | -\- setdelaymodel specify internal delay model (state space |
133 | | - only) |
134 | | -\* :func:`rss` create a random continuous state space model |
135 | | -\* :func:`drss` create a random discrete state space model |
136 | | -== ========================== ============================================ |
137 | | -
|
138 | | -
|
139 | | -Data extraction |
140 | | ----------------------------------------------------------------------------- |
141 | | -
|
142 | | -== ========================== ============================================ |
143 | | -\* :func:`tfdata` extract numerators and denominators |
144 | | -\ lti/zpkdata extract zero/pole/gain data |
145 | | -\ lti/ssdata extract state-space matrices |
146 | | -\ lti/dssdata descriptor version of SSDATA |
147 | | -\ frd/frdata extract frequency response data |
148 | | -\ lti/get access values of LTI model properties |
149 | | -\ ss/getDelayModel access internal delay model (state space) |
150 | | -== ========================== ============================================ |
151 | | -
|
152 | | -
|
153 | | -Conversions |
154 | | ----------------------------------------------------------------------------- |
155 | | -
|
156 | | -== ============================ ============================================ |
157 | | -\* :func:`tf` conversion to transfer function |
158 | | -\ zpk conversion to zero/pole/gain |
159 | | -\* :func:`ss` conversion to state space |
160 | | -\* :func:`frd` conversion to frequency data |
161 | | -\* :func:`c2d` continuous to discrete conversion |
162 | | -\ d2c discrete to continuous conversion |
163 | | -\ d2d resample discrete-time model |
164 | | -\ upsample upsample discrete-time LTI systems |
165 | | -\* :func:`ss2tf` state space to transfer function |
166 | | -\s :func:`~scipy.signal.ss2zpk` transfer function to zero-pole-gain |
167 | | -\* :func:`tf2ss` transfer function to state space |
168 | | -\s :func:`~scipy.signal.tf2zpk` transfer function to zero-pole-gain |
169 | | -\s :func:`~scipy.signal.zpk2ss` zero-pole-gain to state space |
170 | | -\s :func:`~scipy.signal.zpk2tf` zero-pole-gain to transfer function |
171 | | -== ============================ ============================================ |
172 | | -
|
173 | | -
|
174 | | -System interconnections |
175 | | ----------------------------------------------------------------------------- |
176 | | -
|
177 | | -== ========================== ============================================ |
178 | | -\* :func:`~control.append` group LTI models by appending inputs/outputs |
179 | | -\* :func:`~control.parallel` connect LTI models in parallel |
180 | | - (see also overloaded ``+``) |
181 | | -\* :func:`~control.series` connect LTI models in series |
182 | | - (see also overloaded ``*``) |
183 | | -\* :func:`~control.feedback` connect lti models with a feedback loop |
184 | | -\ lti/lft generalized feedback interconnection |
185 | | -\* :func:`~control.connect` arbitrary interconnection of lti models |
186 | | -\ sumblk summing junction (for use with connect) |
187 | | -\ strseq builds sequence of indexed strings |
188 | | - (for I/O naming) |
189 | | -== ========================== ============================================ |
190 | | -
|
191 | | -
|
192 | | -System gain and dynamics |
193 | | ----------------------------------------------------------------------------- |
194 | | -
|
195 | | -== ========================== ============================================ |
196 | | -\* :func:`dcgain` steady-state (D.C.) gain |
197 | | -\* :func:`bandwidth` system bandwidth |
198 | | -\ lti/norm h2 and Hinfinity norms of LTI models |
199 | | -\* :func:`pole` system poles |
200 | | -\* :func:`zero` system (transmission) zeros |
201 | | -\ lti/order model order (number of states) |
202 | | -\* :func:`~control.pzmap` pole-zero map (TF only) |
203 | | -\ lti/iopzmap input/output pole-zero map |
204 | | -\* :func:`damp` natural frequency, damping of system poles |
205 | | -\ esort sort continuous poles by real part |
206 | | -\ dsort sort discrete poles by magnitude |
207 | | -\ lti/stabsep stable/unstable decomposition |
208 | | -\ lti/modsep region-based modal decomposition |
209 | | -== ========================== ============================================ |
210 | | -
|
211 | | -
|
212 | | -Time-domain analysis |
213 | | ----------------------------------------------------------------------------- |
214 | | -
|
215 | | -== ========================== ============================================ |
216 | | -\* :func:`step` step response |
217 | | -\ stepinfo step response characteristics |
218 | | -\* :func:`impulse` impulse response |
219 | | -\* :func:`initial` free response with initial conditions |
220 | | -\* :func:`lsim` response to user-defined input signal |
221 | | -\ lsiminfo linear response characteristics |
222 | | -\ gensig generate input signal for LSIM |
223 | | -\ covar covariance of response to white noise |
224 | | -== ========================== ============================================ |
225 | | -
|
226 | | -
|
227 | | -Frequency-domain analysis |
228 | | ----------------------------------------------------------------------------- |
229 | | -
|
230 | | -== ========================== ============================================ |
231 | | -\* :func:`bode` Bode plot of the frequency response |
232 | | -\ lti/bodemag Bode magnitude diagram only |
233 | | -\ sigma singular value frequency plot |
234 | | -\* :func:`~control.nyquist` Nyquist plot |
235 | | -\* :func:`~control.nichols` Nichols plot |
236 | | -\* :func:`margin` gain and phase margins |
237 | | -\ lti/allmargin all crossover frequencies and margins |
238 | | -\* :func:`freqresp` frequency response |
239 | | -\* :func:`evalfr` frequency response at complex frequency s |
240 | | -== ========================== ============================================ |
241 | | -
|
242 | | -
|
243 | | -Model simplification |
244 | | ----------------------------------------------------------------------------- |
245 | | -
|
246 | | -== ========================== ============================================ |
247 | | -\* :func:`~control.minreal` minimal realization; pole/zero cancellation |
248 | | -\ ss/sminreal structurally minimal realization |
249 | | -\* :func:`~control.hsvd` hankel singular values (state contributions) |
250 | | -\* :func:`~control.balred` reduced-order approximations of LTI models |
251 | | -\* :func:`~control.modred` model order reduction |
252 | | -== ========================== ============================================ |
253 | | -
|
254 | | -
|
255 | | -Compensator design |
256 | | ----------------------------------------------------------------------------- |
257 | | -
|
258 | | -== ========================== ============================================ |
259 | | -\* :func:`rlocus` evans root locus |
260 | | -\* :func:`sisotool` SISO controller design |
261 | | -\* :func:`~control.place` pole placement |
262 | | -\ estim form estimator given estimator gain |
263 | | -\ reg form regulator given state-feedback and |
264 | | - estimator gains |
265 | | -== ========================== ============================================ |
266 | | -
|
267 | | -
|
268 | | -LQR/LQG design |
269 | | ----------------------------------------------------------------------------- |
270 | | -
|
271 | | -== ========================== ============================================ |
272 | | -\ ss/lqg single-step LQG design |
273 | | -\* :func:`~control.lqr` linear quadratic (LQ) state-fbk regulator |
274 | | -\ dlqr discrete-time LQ state-feedback regulator |
275 | | -\ lqry LQ regulator with output weighting |
276 | | -\ lqrd discrete LQ regulator for continuous plant |
277 | | -\ ss/lqi Linear-Quadratic-Integral (LQI) controller |
278 | | -\ ss/kalman Kalman state estimator |
279 | | -\ ss/kalmd discrete Kalman estimator for cts plant |
280 | | -\ ss/lqgreg build LQG regulator from LQ gain and Kalman |
281 | | - estimator |
282 | | -\ ss/lqgtrack build LQG servo-controller |
283 | | -\ augstate augment output by appending states |
284 | | -== ========================== ============================================ |
285 | | -
|
286 | | -
|
287 | | -State-space (SS) models |
288 | | ----------------------------------------------------------------------------- |
289 | | -
|
290 | | -== ========================== ============================================ |
291 | | -\* :func:`rss` random stable cts-time state-space models |
292 | | -\* :func:`drss` random stable disc-time state-space models |
293 | | -\ ss2ss state coordinate transformation |
294 | | -\ canon canonical forms of state-space models |
295 | | -\* :func:`~control.ctrb` controllability matrix |
296 | | -\* :func:`~control.obsv` observability matrix |
297 | | -\* :func:`~control.gram` controllability and observability gramians |
298 | | -\ ss/prescale optimal scaling of state-space models. |
299 | | -\ balreal gramian-based input/output balancing |
300 | | -\ ss/xperm reorder states. |
301 | | -== ========================== ============================================ |
302 | | -
|
303 | | -
|
304 | | -Frequency response data (FRD) models |
305 | | ----------------------------------------------------------------------------- |
306 | | -
|
307 | | -== ========================== ============================================ |
308 | | -\ frd/chgunits change frequency vector units |
309 | | -\ frd/fcat merge frequency responses |
310 | | -\ frd/fselect select frequency range or subgrid |
311 | | -\ frd/fnorm peak gain as a function of frequency |
312 | | -\ frd/abs entrywise magnitude of frequency response |
313 | | -\ frd/real real part of the frequency response |
314 | | -\ frd/imag imaginary part of the frequency response |
315 | | -\ frd/interp interpolate frequency response data |
316 | | -\* :func:`~control.mag2db` convert magnitude to decibels (dB) |
317 | | -\* :func:`~control.db2mag` convert decibels (dB) to magnitude |
318 | | -== ========================== ============================================ |
319 | | -
|
320 | | -
|
321 | | -Time delays |
322 | | ----------------------------------------------------------------------------- |
323 | | -
|
324 | | -== ========================== ============================================ |
325 | | -\ lti/hasdelay true for models with time delays |
326 | | -\ lti/totaldelay total delay between each input/output pair |
327 | | -\ lti/delay2z replace delays by poles at z=0 or FRD phase |
328 | | - shift |
329 | | -\* :func:`~control.pade` pade approximation of time delays |
330 | | -== ========================== ============================================ |
331 | | -
|
332 | | -
|
333 | | -Model dimensions and characteristics |
334 | | ----------------------------------------------------------------------------- |
335 | | -
|
336 | | -== ========================== ============================================ |
337 | | -\ class model type ('tf', 'zpk', 'ss', or 'frd') |
338 | | -\ isa test if model is of given type |
339 | | -\ tf/size model sizes |
340 | | -\ lti/ndims number of dimensions |
341 | | -\ lti/isempty true for empty models |
342 | | -\ lti/isct true for continuous-time models |
343 | | -\ lti/isdt true for discrete-time models |
344 | | -\ lti/isproper true for proper models |
345 | | -\ lti/issiso true for single-input/single-output models |
346 | | -\ lti/isstable true for models with stable dynamics |
347 | | -\ lti/reshape reshape array of linear models |
348 | | -== ========================== ============================================ |
349 | | -
|
350 | | -Overloaded arithmetic operations |
351 | | ----------------------------------------------------------------------------- |
352 | | -
|
353 | | -== ========================== ============================================ |
354 | | -\* \+ and - add, subtract systems (parallel connection) |
355 | | -\* \* multiply systems (series connection) |
356 | | -\ / right divide -- sys1\*inv(sys2) |
357 | | -\- \\ left divide -- inv(sys1)\*sys2 |
358 | | -\ ^ powers of a given system |
359 | | -\ ' pertransposition |
360 | | -\ .' transposition of input/output map |
361 | | -\ .\* element-by-element multiplication |
362 | | -\ [..] concatenate models along inputs or outputs |
363 | | -\ lti/stack stack models/arrays along some dimension |
364 | | -\ lti/inv inverse of an LTI system |
365 | | -\ lti/conj complex conjugation of model coefficients |
366 | | -== ========================== ============================================ |
367 | | -
|
368 | | -Matrix equation solvers and linear algebra |
369 | | ----------------------------------------------------------------------------- |
370 | | -
|
371 | | -== ========================== ============================================ |
372 | | -\* :func:`~control.lyap` solve continuous-time Lyapunov equations |
373 | | -\* :func:`~control.dlyap` solve discrete-time Lyapunov equations |
374 | | -\ lyapchol, dlyapchol square-root Lyapunov solvers |
375 | | -\* :func:`~control.care` solve continuous-time algebraic Riccati |
376 | | - equations |
377 | | -\* :func:`~control.dare` solve disc-time algebraic Riccati equations |
378 | | -\ gcare, gdare generalized Riccati solvers |
379 | | -\ bdschur block diagonalization of a square matrix |
380 | | -== ========================== ============================================ |
381 | | -
|
382 | | -
|
383 | | -Additional functions |
384 | | ----------------------------------------------------------------------------- |
385 | | -
|
386 | | -== ========================== ============================================ |
387 | | -\* :func:`~control.gangof4` generate the Gang of 4 sensitivity plots |
388 | | -\* :func:`~numpy.linspace` generate a set of numbers that are linearly |
389 | | - spaced |
390 | | -\* :func:`~numpy.logspace` generate a set of numbers that are |
391 | | - logarithmically spaced |
392 | | -\* :func:`~control.unwrap` unwrap phase angle to give continuous curve |
393 | | -== ========================== ============================================ |
394 | | -
|
395 | | -""" |
0 commit comments