Skip to content

Commit 76d51ff

Browse files
authored
Merge pull request #577 from bnavigator/mimo-step-info
enhance step_info to MIMO and time series of response data
2 parents 992bf0e + a878846 commit 76d51ff

File tree

4 files changed

+533
-292
lines changed

4 files changed

+533
-292
lines changed

control/matlab/timeresp.py

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -64,38 +64,59 @@ def step(sys, T=None, X0=0., input=0, output=None, return_x=False):
6464
transpose=True, return_x=return_x)
6565
return (out[1], out[0], out[2]) if return_x else (out[1], out[0])
6666

67-
def stepinfo(sys, T=None, SettlingTimeThreshold=0.02,
67+
68+
def stepinfo(sysdata, T=None, yfinal=None, SettlingTimeThreshold=0.02,
6869
RiseTimeLimits=(0.1, 0.9)):
69-
'''
70+
"""
7071
Step response characteristics (Rise time, Settling Time, Peak and others).
7172
7273
Parameters
7374
----------
74-
sys: StateSpace, or TransferFunction
75-
LTI system to simulate
76-
77-
T: array-like or number, optional
75+
sysdata : StateSpace or TransferFunction or array_like
76+
The system data. Either LTI system to similate (StateSpace,
77+
TransferFunction), or a time series of step response data.
78+
T : array_like or float, optional
7879
Time vector, or simulation time duration if a number (time vector is
79-
autocomputed if not given)
80-
81-
SettlingTimeThreshold: float value, optional
80+
autocomputed if not given).
81+
Required, if sysdata is a time series of response data.
82+
yfinal : scalar or array_like, optional
83+
Steady-state response. If not given, sysdata.dcgain() is used for
84+
systems to simulate and the last value of the the response data is
85+
used for a given time series of response data. Scalar for SISO,
86+
(noutputs, ninputs) array_like for MIMO systems.
87+
SettlingTimeThreshold : float, optional
8288
Defines the error to compute settling time (default = 0.02)
83-
84-
RiseTimeLimits: tuple (lower_threshold, upper_theshold)
89+
RiseTimeLimits : tuple (lower_threshold, upper_theshold)
8590
Defines the lower and upper threshold for RiseTime computation
8691
8792
Returns
8893
-------
89-
S: a dictionary containing:
90-
RiseTime: Time from 10% to 90% of the steady-state value.
91-
SettlingTime: Time to enter inside a default error of 2%
92-
SettlingMin: Minimum value after RiseTime
93-
SettlingMax: Maximum value after RiseTime
94-
Overshoot: Percentage of the Peak relative to steady value
95-
Undershoot: Percentage of undershoot
96-
Peak: Absolute peak value
97-
PeakTime: time of the Peak
98-
SteadyStateValue: Steady-state value
94+
S : dict or list of list of dict
95+
If `sysdata` corresponds to a SISO system, S is a dictionary
96+
containing:
97+
98+
RiseTime:
99+
Time from 10% to 90% of the steady-state value.
100+
SettlingTime:
101+
Time to enter inside a default error of 2%
102+
SettlingMin:
103+
Minimum value after RiseTime
104+
SettlingMax:
105+
Maximum value after RiseTime
106+
Overshoot:
107+
Percentage of the Peak relative to steady value
108+
Undershoot:
109+
Percentage of undershoot
110+
Peak:
111+
Absolute peak value
112+
PeakTime:
113+
time of the Peak
114+
SteadyStateValue:
115+
Steady-state value
116+
117+
If `sysdata` corresponds to a MIMO system, `S` is a 2D list of dicts.
118+
To get the step response characteristics from the j-th input to the
119+
i-th output, access ``S[i][j]``
99120
100121
101122
See Also
@@ -105,11 +126,13 @@ def stepinfo(sys, T=None, SettlingTimeThreshold=0.02,
105126
Examples
106127
--------
107128
>>> S = stepinfo(sys, T)
108-
'''
129+
"""
109130
from ..timeresp import step_info
110131

111132
# Call step_info with MATLAB defaults
112-
S = step_info(sys, T, None, SettlingTimeThreshold, RiseTimeLimits)
133+
S = step_info(sysdata, T=T, T_num=None, yfinal=yfinal,
134+
SettlingTimeThreshold=SettlingTimeThreshold,
135+
RiseTimeLimits=RiseTimeLimits)
113136

114137
return S
115138

control/tests/sisotool_test.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ def test_sisotool(self, sys):
6868

6969
# Check the step response before moving the point
7070
step_response_original = np.array(
71-
[0. , 0.021 , 0.124 , 0.3146, 0.5653, 0.8385, 1.0969, 1.3095,
72-
1.4549, 1.5231])
71+
[0. , 0.0216, 0.1271, 0.3215, 0.5762, 0.8522, 1.1114, 1.3221,
72+
1.4633, 1.5254])
7373
assert_array_almost_equal(
7474
ax_step.lines[0].get_data()[1][:10], step_response_original, 4)
7575

@@ -113,8 +113,8 @@ def test_sisotool(self, sys):
113113

114114
# Check if the step response has changed
115115
step_response_moved = np.array(
116-
[0. , 0.023 , 0.1554, 0.4401, 0.8646, 1.3722, 1.875 , 2.2709,
117-
2.4633, 2.3827])
116+
[0. , 0.0237, 0.1596, 0.4511, 0.884 , 1.3985, 1.9031, 2.2922,
117+
2.4676, 2.3606])
118118
assert_array_almost_equal(
119119
ax_step.lines[0].get_data()[1][:10], step_response_moved, 4)
120120

@@ -157,7 +157,3 @@ def test_sisotool_mimo(self, sys222, sys221):
157157
# but 2 input, 1 output should
158158
with pytest.raises(ControlMIMONotImplemented):
159159
sisotool(sys221)
160-
161-
162-
163-

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy