|
3 | 3 | """ |
4 | 4 |
|
5 | 5 | import numpy as np |
| 6 | +from scipy.signal import zpk2tf |
| 7 | +import warnings |
| 8 | +from warnings import warn |
| 9 | + |
6 | 10 | from ..statesp import ss |
7 | 11 | from ..xferfcn import tf |
8 | 12 | from ..lti import LTI |
9 | 13 | from ..exception import ControlArgument |
10 | | -from scipy.signal import zpk2tf |
11 | | -from warnings import warn |
12 | 14 |
|
13 | | -__all__ = ['bode', 'nyquist', 'ngrid', 'dcgain'] |
| 15 | +__all__ = ['bode', 'nyquist', 'ngrid', 'dcgain', 'connect'] |
14 | 16 |
|
15 | 17 | def bode(*args, **kwargs): |
16 | 18 | """bode(syslist[, omega, dB, Hz, deg, ...]) |
@@ -230,3 +232,56 @@ def dcgain(*args): |
230 | 232 | else: |
231 | 233 | raise ValueError("Function ``dcgain`` needs either 1, 2, 3 or 4 " |
232 | 234 | "arguments.") |
| 235 | + |
| 236 | + |
| 237 | +from ..bdalg import connect as ct_connect |
| 238 | +def connect(*args): |
| 239 | + """Index-based interconnection of an LTI system. |
| 240 | +
|
| 241 | + The system `sys` is a system typically constructed with `append`, with |
| 242 | + multiple inputs and outputs. The inputs and outputs are connected |
| 243 | + according to the interconnection matrix `Q`, and then the final inputs and |
| 244 | + outputs are trimmed according to the inputs and outputs listed in `inputv` |
| 245 | + and `outputv`. |
| 246 | +
|
| 247 | + NOTE: Inputs and outputs are indexed starting at 1 and negative values |
| 248 | + correspond to a negative feedback interconnection. |
| 249 | +
|
| 250 | + Parameters |
| 251 | + ---------- |
| 252 | + sys : :class:`InputOutputSystem` |
| 253 | + System to be connected. |
| 254 | + Q : 2D array |
| 255 | + Interconnection matrix. First column gives the input to be connected. |
| 256 | + The second column gives the index of an output that is to be fed into |
| 257 | + that input. Each additional column gives the index of an additional |
| 258 | + input that may be optionally added to that input. Negative |
| 259 | + values mean the feedback is negative. A zero value is ignored. Inputs |
| 260 | + and outputs are indexed starting at 1 to communicate sign information. |
| 261 | + inputv : 1D array |
| 262 | + list of final external inputs, indexed starting at 1 |
| 263 | + outputv : 1D array |
| 264 | + list of final external outputs, indexed starting at 1 |
| 265 | +
|
| 266 | + Returns |
| 267 | + ------- |
| 268 | + out : :class:`InputOutputSystem` |
| 269 | + Connected and trimmed I/O system. |
| 270 | +
|
| 271 | + See Also |
| 272 | + -------- |
| 273 | + append, feedback, interconnect, negate, parallel, series |
| 274 | +
|
| 275 | + Examples |
| 276 | + -------- |
| 277 | + >>> G = ct.rss(7, inputs=2, outputs=2) |
| 278 | + >>> K = [[1, 2], [2, -1]] # negative feedback interconnection |
| 279 | + >>> T = ct.connect(G, K, [2], [1, 2]) |
| 280 | + >>> T.ninputs, T.noutputs, T.nstates |
| 281 | + (1, 2, 7) |
| 282 | +
|
| 283 | + """ |
| 284 | + # Turn off the deprecation warning |
| 285 | + with warnings.catch_warnings(): |
| 286 | + warnings.filterwarnings('ignore', message="`connect` is deprecated") |
| 287 | + return ct_connect(*args) |
0 commit comments