8000 Describe MIMO step_info return and add doctest example · basicmachines/python-control@20ed368 · GitHub
[go: up one dir, main page]

Skip to content

Commit 20ed368

Browse files
committed
Describe MIMO step_info return and add doctest example
1 parent 01ef666 commit 20ed368

File tree

1 file changed

+45
-4
lines changed

1 file changed

+45
-4
lines changed

control/timeresp.py

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ def step_response(sys, T=None, X0=0., input=None, output=None, T_num=None,
740740

741741
def step_info(sys, T=None, T_num=None, SettlingTimeThreshold=0.02,
742742
RiseTimeLimits=(0.1, 0.9)):
743-
'''
743+
"""
744744
Step response characteristics (Rise time, Settling Time, Peak and others).
745745
746746
Parameters
@@ -781,7 +781,9 @@ def step_info(sys, T=None, T_num=None, SettlingTimeThreshold=0.02,
781781
SteadyStateValue:
782782
Steady-state value
783783
784-
If `sys` is a MIMO system, S is a 2D-List of dicts.
784+
If `sys` is a MIMO system, `S` is a 2D list of dicts. To get the
785+
step response characteristics from the j-th input to the i-th output,
786+
access ``S[i][j]``
785787
786788
787789
See Also
@@ -790,8 +792,47 @@ def step_info(sys, T=None, T_num=None, SettlingTimeThreshold=0.02,
790792
791793
Examples
792794
--------
793-
>>> info = step_info(sys, T)
794-
'''
795+
>>> from control import step_info, TransferFunction
796+
>>> sys = TransferFunction([-1, 1], [1, 1, 1])
797+
>>> S = step_info(sys)
798+
>>> for k in S:
799+
... print(f"{k}: {S[k]:3.4}")
800+
...
801+
RiseTime: 1.256
802+
SettlingTime: 9.071
803+
SettlingMin: 0.9011
804+
SettlingMax: 1.208
805+
Overshoot: 20.85
806+
Undershoot: 27.88
807+
Peak: 1.208
808+
PeakTime: 4.187
809+
SteadyStateValue: 1.0
810+
811+
MIMO System: Simulate until a final time of 10. Get the step response
812+
characteristics for the second input and specify a 5% error until the
813+
signal is considered settled.
814+
815+
>>> from numpy import sqrt
816+
>>> from control import step_info, StateSpace
817+
>>> sys = StateSpace([[-1., -1.],
818+
... [1., 0.]],
819+
... [[-1./sqrt(2.), 1./sqrt(2.)],
820+
... [0, 0]],
821+
... [[sqrt(2.), -sqrt(2.)]],
822+
... [[0, 0]])
823+
>>> S = step_info(sys, T=10., SettlingTimeThreshold=0.05)
824+
>>> for k, v in S[0][1].items():
825+
... print(f"{k}: {float(v):3.4}")
826+
RiseTime: 1.212
827+
SettlingTime: 6.061
828+
SettlingMin: -1.209
829+
SettlingMax: -0.9184
830+
Overshoot: 20.87
831+
Undershoot: 28.02
832+
Peak: 1.209
833+
PeakTime: 4.242
834+
SteadyStateValue: -1.0
835+
"""
795836
if T is None or np.asarray(T).size == 1:
796837
T = _default_time_vector(sys, N=T_num, tfinal=T, is_step=True)
797838
T, Yout = step_response(sys, T, squeeze=False)

0 commit comments

Comments
 (0)
0