@@ -1358,6 +1358,12 @@ def step_response(sys, T=None, X0=0., input=None, output=None, T_num=None,
13581358 xout = np .empty ((sys .nstates , ninputs , np .asarray (T ).size ))
13591359 uout = np .empty ((ninputs , ninputs , np .asarray (T ).size ))
13601360
1361+ # Get labels for the inputs/outputs (prior to mimo -> simo conversion)
1362+ input_labels = sys .input_labels if input is None \
1363+ else [sys .input_labels [input ]]
1364+ output_labels = sys .output_labels if output is None \
1365+ else [sys .output_labels [output ]]
1366+
13611367 # Simulate the response for each input
13621368 for i in range (sys .ninputs ):
13631369 # If input keyword was specified, only simulate for that input
@@ -1376,12 +1382,6 @@ def step_response(sys, T=None, X0=0., input=None, output=None, T_num=None,
13761382 # Figure out if the system is SISO or not
13771383 issiso = sys .issiso () or (input is not None and output is not None )
13781384
1379- # Select only the given input and output, if any
1380- input_labels = sys .input_labels if input is None \
1381- else [sys .input_labels [input ]]
1382- output_labels = sys .output_labels if output is None \
1383- else [sys .output_labels [output ]]
1384-
13851385 return TimeResponseData (
13861386 response .time , yout , xout , uout , issiso = issiso ,
13871387 output_labels = output_labels , input_labels = input_labels ,
@@ -1701,6 +1701,10 @@ def initial_response(sys, T=None, X0=0., input=0, output=None, T_num=None,
17011701 >>> T, yout = ct.initial_response(G)
17021702
17031703 """
1704+ # Get labels for the inputs/outputs (prior to mimo -> simo conversion)
1705+ output_labels = sys .output_labels if output is None \
1706+ else [sys .output_labels [output ]]
1707+
17041708 squeeze , sys = _get_ss_simo (sys , input , output , squeeze = squeeze )
17051709
17061710 # Create time and input vectors; checking is done in forced_response(...)
@@ -1714,10 +1718,6 @@ def initial_response(sys, T=None, X0=0., input=0, output=None, T_num=None,
17141718 # Figure out if the system is SISO or not
17151719 issiso = sys .issiso () or (input is not None and output is not None )
17161720
1717- # Select only the given output, if any
1718- output_labels = sys .output_labels if output is None \
1719- else [sys .output_labels [output ]]
1720-
17211721 # Store the response without an input
17221722 return TimeResponseData (
17231723 response .t , response .y , response .x , None , issiso = issiso ,
@@ -1814,7 +1814,7 @@ def impulse_response(sys, T=None, X0=0., input=None, output=None, T_num=None,
18141814 -----
18151815 This function uses the `forced_response` function to compute the time
18161816 response. For continuous time systems, the initial condition is altered to
1817- account for the initial impulse. For discrete-time aystems, the impulse is
1817+ account for the initial impulse. For discrete-time aystems, the impulse is
18181818 sized so that it has unit area.
18191819
18201820 Examples
@@ -1851,6 +1851,12 @@ def impulse_response(sys, T=None, X0=0., input=None, output=None, T_num=None,
18511851 xout = np .empty ((sys .nstates , ninputs , np .asarray (T ).size ))
18521852 uout = np .full ((ninputs , ninputs , np .asarray (T ).size ), None )
18531853
1854+ # Get labels for the inputs/outputs (prior to mimo -> simo conversion)
1855+ input_labels = sys .input_labels if input is None \
1856+ else [sys .input_labels [input ]]
1857+ output_labels = sys .output_labels if output is None \
1858+ else [sys .output_labels [output ]]
1859+
18541860 # Simulate the response for each input
18551861 for i in range (sys .ninputs ):
18561862 # If input keyword was specified, only handle that case
@@ -1885,12 +1891,6 @@ def impulse_response(sys, T=None, X0=0., input=None, output=None, T_num=None,
18851891 # Figure out if the system is SISO or not
18861892 issiso = sys .issiso () or (input is not None and output is not None )
18871893
1888- # Select only the given input and output, if any
1889- input_labels = sys .input_labels if input is None \
1890- else [sys .input_labels [input ]]
1891- output_labels = sys .output_labels if output is None \
1892- else [sys .output_labels [output ]]
1893-
18941894 return TimeResponseData (
18951895 response .time , yout , xout , uout , issiso = issiso ,
18961896 output_labels = output_labels , input_labels = input_labels ,
0 commit comments