@@ -1227,7 +1227,7 @@ def dcgain(self, warn_infinite=False):
12271227 return self (0 , warn_infinite = warn_infinite ) if self .isctime () \
12281228 else self (1 , warn_infinite = warn_infinite )
12291229
1230- def dynamics (self , * args ):
1230+ def dynamics (self , t , x , u = 0 ):
12311231 """Compute the dynamics of the system
12321232
12331233 Given input `u` and state `x`, returns the dynamics of the state-space
@@ -1242,11 +1242,10 @@ def dynamics(self, *args):
12421242
12431243 The inputs `x` and `u` must be of the correct length for the system.
12441244
1245- The calling signature is ``out = sys.dynamics(t, x[, u])``
12461245 The first argument `t` is ignored because :class:`StateSpace` systems
12471246 are time-invariant. It is included so that the dynamics can be passed
1248- to most numerical integrators, such as scipy's ` integrate.solve_ivp` and
1249- for consistency with :class:`IOSystem` systems.
1247+ to most numerical integrators, such as :func:`scipy. integrate.solve_ivp`
1248+ and for consistency with :class:`IOSystem` systems.
12501249
12511250 Parameters
12521251 ----------
@@ -1261,23 +1260,19 @@ def dynamics(self, *args):
12611260 -------
12621261 dx/dt or x[t+dt] : ndarray
12631262 """
1264- if len (args ) not in (2 , 3 ):
1265- raise ValueError ("received" + len (args ) + "args, expected 2 or 3" )
1266-
1267- x = np .reshape (args [1 ], (- 1 , 1 )) # force to a column in case matrix
1263+ x = np .reshape (x , (- 1 , 1 )) # force to a column in case matrix
12681264 if np .size (x ) != self .nstates :
12691265 raise ValueError ("len(x) must be equal to number of states" )
1270-
1271- if len (args ) == 2 : # received t and x, ignore t
1266+ if u is 0 :
12721267 return self .A .dot (x ).reshape ((- 1 ,)) # return as row vector
12731268 else : # received t, x, and u, ignore t
1274- u = np .reshape (args [ 2 ] , (- 1 , 1 )) # force to a column in case matrix
1269+ u = np .reshape (u , (- 1 , 1 )) # force to a column in case matrix
12751270 if np .size (u ) != self .ninputs :
12761271 raise ValueError ("len(u) must be equal to number of inputs" )
12771272 return self .A .dot (x ).reshape ((- 1 ,)) \
12781273 + self .B .dot (u ).reshape ((- 1 ,)) # return as row vector
12791274
1280- def output (self , * args ):
1275+ def output (self , t , x , u = 0 ):
12811276 """Compute the output of the system
12821277
12831278 Given input `u` and state `x`, returns the output `y` of the
@@ -1287,7 +1282,6 @@ def output(self, *args):
12871282
12881283 where A and B are the state-space matrices of the system.
12891284
1290- The calling signature is ``y = sys.output(t, x[, u])``
12911285 The first argument `t` is ignored because :class:`StateSpace` systems
12921286 are time-invariant. It is included so that the dynamics can be passed
12931287 to most numerical integrators, such as scipy's `integrate.solve_ivp` and
@@ -1308,17 +1302,14 @@ def output(self, *args):
13081302 -------
13091303 y : ndarray
13101304 """
1311- if len (args ) not in (2 , 3 ):
1312- raise ValueError ("received" + len (args )+ "args, expected 2 or 3" )
1313-
1314- x = np .reshape (args [1 ], (- 1 , 1 )) # force to a column in case matrix
1305+ x = np .reshape (x , (- 1 , 1 )) # force to a column in case matrix
13151306 if np .size (x ) != self .nstates :
13161307 raise ValueError ("len(x) must be equal to number of states" )
13171308
1318- if len ( args ) == 2 : # received t and x, ignore t
1309+ if u is 0 :
13191310 return self .C .dot (x ).reshape ((- 1 ,)) # return as row vector
13201311 else : # received t, x, and u, ignore t
1321- u = np .reshape (args [ 2 ] , (- 1 , 1 )) # force to a column in case matrix
1312+ u = np .reshape (u , (- 1 , 1 )) # force to a column in case matrix
13221313 if np .size (u ) != self .ninputs :
13231314 raise ValueError ("len(u) must be equal to number of inputs" )
13241315 return self .C .dot (x ).reshape ((- 1 ,)) \
0 commit comments