Skip to content

Commit c257fa4

Browse files
committed
make matlab compatibilty match the output order of matlab
1 parent 3582040 commit c257fa4

1 file changed

Lines changed: 25 additions & 9 deletions

File tree

control/matlab/timeresp.py

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ def step(sys, T=None, X0=0., input=0, output=None, return_x=False):
4040
yout: array
4141
Response of the system
4242
43-
xout: array (if selected)
44-
Individual response of each x variable
45-
4643
T: array
4744
Time values of the output
4845
46+
xout: array (if selected)
47+
Individual response of each x variable
48+
4949
5050
5151
See Also
@@ -62,11 +62,11 @@ def step(sys, T=None, X0=0., input=0, output=None, return_x=False):
6262
transpose = True, return_x=True)
6363

6464
if return_x:
65-
return yout, xout, T
65+
return yout, T, xout
6666

6767
return yout, T
6868

69-
def impulse(sys, T=None, input=0, output=None):
69+
def impulse(sys, T=None, input=0, output=None, return_x=False):
7070
'''
7171
Impulse response of a linear system
7272
@@ -94,9 +94,13 @@ def impulse(sys, T=None, input=0, output=None):
9494
-------
9595
yout: array
9696
Response of the system
97+
9798
T: array
9899
Time values of the output
99100
101+
xout: array (if selected)
102+
Individual response of each x variable
103+
100104
See Also
101105
--------
102106
lsim, step, initial
@@ -106,8 +110,12 @@ def impulse(sys, T=None, input=0, output=None):
106110
>>> yout, T = impulse(sys, T)
107111
'''
108112
from ..timeresp import impulse_response
109-
T, yout = impulse_response(sys, T, 0, input, output,
110-
transpose = True)
113+
T, yout, xout = impulse_response(sys, T, 0, input, output,
114+
transpose = True, return_x=True)
115+
116+
if return_x:
117+
return yout, T, xout
118+
111119
return yout, T
112120

113121
def initial(sys, T=None, X0=0., input=None, output=None):
@@ -142,9 +150,13 @@ def initial(sys, T=None, X0=0., input=None, output=None):
142150
-------
143151
yout: array
144152
Response of the system
153+
145154
T: array
146155
Time values of the output
147156
157+
xout: array (if selected)
158+
Individual response of each x variable
159+
148160
See Also
149161
--------
150162
lsim, step, impulse
@@ -155,8 +167,12 @@ def initial(sys, T=None, X0=0., input=None, output=None):
155167
156168
'''
157169
from ..timeresp import initial_response
158-
T, yout = initial_response(sys, T, X0, output=output,
159-
transpose=True)
170+
T, yout, xout = initial_response(sys, T, X0, output=output,
171+
transpose=True, return_x=True)
172+
173+
if return_x:
174+
return yout, T, xout
175+
160176
return yout, T
161177

162178
def lsim(sys, U=0., T=None, X0=0.):

0 commit comments

Comments
 (0)