8000 fix timevector and list return population for MIMO step_info · basicmachines/python-control@35d8eba · GitHub
[go: up one dir, main page]

Skip to content

Commit 35d8eba

Browse files
committed
fix timevector and list return population for MIMO step_info
1 parent ed63358 commit 35d8eba

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

control/timeresp.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -793,16 +793,17 @@ def step_info(sys, T=None, T_num=None, SettlingTimeThreshold=0.02,
793793
--------
794794
>>> info = step_info(sys, T)
795795
'''
796-
797-
798-
if T is None or np.asarray(T).size == 1:
799-
T = _default_time_vector(sys, N=T_num, tfinal=T, is_step=True)
800-
801-
ret = [[None] * sys.ninputs] * sys.noutputs
796+
ret = []
802797
for i in range(sys.noutputs):
798+
retrow = []
803799
for j in range(sys.ninputs):
804800
sys_siso = sys[i, j]
805-
T, yout = step_response(sys_siso, T)
801+
if T is None or np.asarray(T).size == 1:
802+
Ti = _default_time_vector(sys_siso, N=T_num, tfinal=T,
803+
is_step=True)
804+
else:
805+
Ti = T
806+
Ti, yout = step_response(sys_siso, Ti)
806807

807808
# Steady state value
808809
InfValue = sys_siso.dcgain()
@@ -826,12 +827,12 @@ def step_info(sys, T=None, T_num=None, SettlingTimeThreshold=0.02,
826827
tr_upper_index = np.where(
827828
sgnInf * (yout - RiseTimeLimits[1] * InfValue) >= 0
828829
)[0][0]
829-
rise_time = T[tr_upper_index] - T[tr_lower_index]
830+
rise_time = Ti[tr_upper_index] - Ti[tr_lower_index]
830831

831832
# SettlingTime
832833
settling_th = np.abs(SettlingTimeThreshold * InfValue)
833834
not_settled = np.where(np.abs(yout - InfValue) >= settling_th)
834-
settling_time = T[not_settled[0][-1] + 1]
835+
settling_time = Ti[not_settled[0][-1] + 1]
835836

836837
settling_min = (yout[tr_upper_index:]).min()
837838
settling_max = (yout[tr_upper_index:]).max()
@@ -855,12 +856,12 @@ def step_info(sys, T=None, T_num=None, SettlingTimeThreshold=0.02,
855856
# Peak
856857
peak_index = np.abs(yout).argmax()
857858
peak_value = np.abs(yout[peak_index])
858-
peak_time = T[peak_index]
859+
peak_time = Ti[peak_index]
859860

860861
# SteadyStateValue
861862
steady_state_value = InfValue
862863

863-
ret[i][j] = {
864+
retij = {
864865
'RiseTime': rise_time,
865866
'SettlingTime': settling_time,
866867
'SettlingMin': settling_min,
@@ -871,6 +872,9 @@ def step_info(sys, T=None, T_num=None, SettlingTimeThreshold=0.02,
871872
'PeakTime': peak_time,
872873
'SteadyStateValue': steady_state_value
873874
}
875+
retrow.append(retij)
876+
877+
ret.append(retrow)
874878

875879
return ret[0][0] if sys.issiso() else ret
876880

0 commit comments

Comments
 (0)
0