134134\- lti/set set/modify properties of LTI models
135135\- setdelaymodel specify internal delay model (state space
136136 only)
137+ \* :func:`rss` create a random continuous state space model
138+ \* :func:`drss` create a random discrete state space model
137139== ========================== ============================================
138140
139141
140142Data extraction
141143----------------------------------------------------------------------------
142144
143145== ========================== ============================================
144- \ lti/ tfdata extract numerators and denominators
146+ \* :func:` tfdata` extract numerators and denominators
145147\ lti/zpkdata extract zero/pole/gain data
146148\ lti/ssdata extract state-space matrices
147149\ lti/dssdata descriptor version of SSDATA
159161\ zpk conversion to zero/pole/gain
160162\* :func:`ss` conversion to state space
161163\* :func:`frd` conversion to frequency data
162- \ c2d continuous to discrete conversion
164+ \* :func:` c2d` continuous to discrete conversion
163165\ d2c discrete to continuous conversion
164166\ d2d resample discrete-time model
165167\ upsample upsample discrete-time LTI systems
183185 (see also overloaded ``*``)
184186\* :func:`~bdalg.feedback` connect lti models with a feedback loop
185187\ lti/lft generalized feedback interconnection
186- \ lti/ connect arbitrary interconnection of lti models
188+ \* :func:'~bdalg. connect' arbitrary interconnection of lti models
187189\ sumblk summing junction (for use with connect)
188190\ strseq builds sequence of indexed strings
189191 (for I/O naming)
@@ -1101,8 +1103,8 @@ def rlocus(sys, klist = None, **keywords):
11011103 """Root locus plot
11021104
11031105 The root-locus plot has a callback function that prints pole location,
1104- gain and damping to the Python consol on mouseclicks on the root-locus
1105- graph.
1106+ gain and damping to the Python console on mouseclicks on the root-locus
1107+ graph.
11061108
11071109 Parameters
11081110 ----------
@@ -1111,6 +1113,17 @@ def rlocus(sys, klist = None, **keywords):
11111113 klist:
11121114 optional list of gains
11131115
1116+ Keyword parameters
1117+ ------------------
1118+ xlim : control of x-axis range, normally with tuple, for
1119+ other options, see matplotlib.axes
1120+ ylim : control of y-axis range
1121+ Plot : boolean (default = True)
1122+ If True, plot magnitude and phase
1123+ PrintGain: boolean (default = True)
1124+ If True, report mouse clicks when close to the root-locus branches,
1125+ calculate gain, damping and print
1126+
11141127 Returns
11151128 -------
11161129 rlist:
@@ -1155,7 +1168,7 @@ def margin(*args):
11551168 margin: no magnitude crossings found
11561169
11571170 .. todo::
1158- better ecample system!
1171+ better example system!
11591172
11601173 #>>> gm, pm, wg, wp = margin(mag, phase, w)
11611174 """
@@ -1168,7 +1181,7 @@ def margin(*args):
11681181 raise ValueError ("Margin needs 1 or 3 arguments; received %i."
11691182 % len (args ))
11701183
1171- return margin [0 ], margin [1 ], margin [4 ], margin [3 ]
1184+ return margin [0 ], margin [1 ], margin [3 ], margin [4 ]
11721185
11731186def dcgain (* args ):
11741187 '''
@@ -1269,10 +1282,11 @@ def step(sys, T=None, X0=0., input=0, output=None, **keywords):
12691282 '''
12701283 Step response of a linear system
12711284
1272- If the system has multiple inputs or outputs (MIMO), one input and one
1273- output have to be selected for the simulation. The parameters `input`
1274- and `output` do this. All other inputs are set to 0, all other outputs
1275- are ignored.
1285+ If the system has multiple inputs or outputs (MIMO), one input has
1286+ to be selected for the simulation. Optionally, one output may be
1287+ selected. If no selection is made for the output, all outputs are
1288+ given. The parameters `input` and `output` do this. All other
1289+ inputs are set to 0, all other outputs are ignored.
12761290
12771291 Parameters
12781292 ----------
@@ -1291,7 +1305,7 @@ def step(sys, T=None, X0=0., input=0, output=None, **keywords):
12911305 Index of the input that will be used in this simulation.
12921306
12931307 output: int
1294- Index of the output that will be used in this simulation.
1308+ If given, index of the output that is returned by this simulation.
12951309
12961310 **keywords:
12971311 Additional keyword arguments control the solution algorithm for the
@@ -1316,19 +1330,21 @@ def step(sys, T=None, X0=0., input=0, output=None, **keywords):
13161330 Examples
13171331 --------
13181332 >>> yout, T = step(sys, T, X0)
1333+
13191334 '''
13201335 T , yout = timeresp .step_response (sys , T , X0 , input , output ,
1321- transpose = True , ** keywords )
1336+ transpose = True , ** keywords )
13221337 return yout , T
13231338
1324- def impulse (sys , T = None , input = 0 , output = 0 , ** keywords ):
1339+ def impulse (sys , T = None , input = 0 , output = None , ** keywords ):
13251340 '''
13261341 Impulse response of a linear system
13271342
1328- If the system has multiple inputs or outputs (MIMO), one input and
1329- one output must be selected for the simulation. The parameters
1330- `input` and `output` do this. All other inputs are set to 0, all
1331- other outputs are ignored.
1343+ If the system has multiple inputs or outputs (MIMO), one input has
1344+ to be selected for the simulation. Optionally, one output may be
1345+ selected. If no selection is made for the output, all outputs are
1346+ given. The parameters `input` and `output` do this. All other
1347+ inputs are set to 0, all other outputs are ignored.
13321348
13331349 Parameters
13341350 ----------
@@ -1371,14 +1387,13 @@ def impulse(sys, T=None, input=0, output=0, **keywords):
13711387 transpose = True , ** keywords )
13721388 return yout , T
13731389
1374- def initial (sys , T = None , X0 = 0. , input = 0 , output = 0 , ** keywords ):
1390+ def initial (sys , T = None , X0 = 0. , input = None , output = None , ** keywords ):
13751391 '''
13761392 Initial condition response of a linear system
13771393
1378- If the system has multiple inputs or outputs (MIMO), one input and one
1379- output have to be selected for the simulation. The parameters `input`
1380- and `output` do this. All other inputs are set to 0, all other outputs
1381- are ignored.
1394+ If the system has multiple outputs (?IMO), optionally, one output
1395+ may be selected. If no selection is made for the output, all
1396+ outputs are given.
13821397
13831398 Parameters
13841399 ----------
@@ -1394,10 +1409,11 @@ def initial(sys, T=None, X0=0., input=0, output=0, **keywords):
13941409 Numbers are converted to constant arrays with the correct shape.
13951410
13961411 input: int
1397- Index of the input that will be used in this simulation.
1412+ This input is ignored, but present for compatibility with step
1413+ and impulse.
13981414
13991415 output: int
1400- Index of the output that will be used in this simulation.
1416+ If given, index of the output that is returned by this simulation.
14011417
14021418 **keywords:
14031419 Additional keyword arguments control the solution algorithm for the
@@ -1422,9 +1438,10 @@ def initial(sys, T=None, X0=0., input=0, output=0, **keywords):
14221438 Examples
14231439 --------
14241440 >>> T, yout = initial(sys, T, X0)
1441+
14251442 '''
1426- T , yout = timeresp .initial_response (sys , T , X0 , input , output ,
1427- transpose = True , ** keywords )
1443+ T , yout = timeresp .initial_response (sys , T , X0 , output = output ,
1444+ transpose = True , ** keywords )
14281445 return yout , T
14291446
14301447def lsim (sys , U = 0. , T = None , X0 = 0. , ** keywords ):
@@ -1524,8 +1541,29 @@ def tfdata(sys, **kw):
15241541 return (tf .num , tf .den )
15251542
15261543# Convert a continuous time system to a discrete time system
1527- def c2d (sysc , Ts , method ):
1528- # TODO: add docstring
1544+ def c2d (sysc , Ts , method = 'zoh' ):
1545+ '''
1546+ Return a discrete-time system
1547+
1548+ Parameters
1549+ ----------
1550+ sysc: Lti (StateSpace or TransferFunction), continuous
1551+ System to be converted
1552+
1553+ Ts: number
1554+ Sample time for the conversion
1555+
1556+ method: string, optional
1557+ Method to be applied,
1558+ 'zoh' Zero-order hold on the inputs (default)
1559+ 'foh' First-order hold, currently not implemented
1560+ 'impulse' Impulse-invariant discretization, currently not implemented
1561+ 'tustin' Bilinear (Tustin) approximation, only SISO
1562+ 'matched' Matched pole-zero method, only SISO
1563+ '''
15291564 # Call the sample_system() function to do the work
1530- return sample_system (sysc , Ts , method )
1565+ sysd = sample_system (sysc , Ts , method )
1566+ if isinstance (sysc , StateSpace ) and not isinstance (sysd , StateSpace ):
1567+ return _convertToStateSpace (sysd )
1568+ return sysd
15311569
0 commit comments