Create a nonlinear input/output system.
Creates an InputOutputSystem
for a nonlinear system by specifying a state update function and an output function. The new system can be a continuous or discrete-time system.
StateSpace
)
Function returning the state update function
updfcn(t, x, u, params) -> array
where x
is a 1-D array with shape (nstates,), u
is a 1-D array with shape (ninputs,), t
is a float representing the current time, and params
is a dict containing the values of parameters used by the function.
If a StateSpace
system is passed as the update function, then a nonlinear I/O system is created that implements the linear dynamics of the state space system.
Function returning the output at the given state
outfcn(t, x, u, params) -> array
where the arguments are the same as for updfcn
.
Description of the system inputs. This can be given as an integer count or as a list of strings that name the individual signals. If an integer count is specified, the names of the signal will be of the form ‘s[i]’ (where ‘s’ is one of ‘u’, ‘y’, or ‘x’). If this parameter is not given or given as None, the relevant quantity will be determined when possible based on other information provided to functions using the system.
Description of the system outputs. Same format as inputs
.
Description of the system states. Same format as inputs
.
The timebase for the system, used to specify whether the system is operating in continuous or discrete time. It can have the following values:
dt
= 0: continuous-time system (default)
dt
> 0: discrete-time system with sampling period dt
dt
= True: discrete time with unspecified sampling period
dt
= None: no timebase specified
System name (used for specifying signals). If unspecified, a generic name ‘sys[id]’ is generated with a unique integer id.
Parameter values for the system. Passed to the evaluation functions for the system as default values, overriding internal defaults.
NonlinearIOSystem
Nonlinear input/output system.
Set the prefix for input, output, and state signals. Defaults = ‘u’, ‘y’, ‘x’.
Examples
>>> def kincar_update(t, x, u, params): ... l = params['l'] # wheelbase ... return np.array([ ... np.cos(x[2]) * u[0], # x velocity ... np.sin(x[2]) * u[0], # y velocity ... np.tan(u[1]) * u[0] / l # angular velocity ... ]) >>> >>> def kincar_output(t, x, u, params): ... return x[0:2] # x, y position >>> >>> kincar = ct.nlsys( ... kincar_update, kincar_output, states=3, inputs=2, outputs=2, ... params={'l': 1}) >>> >>> timepts = np.linspace(0, 10) >>> response = ct.input_output_response( ... kincar, timepts, [10, 0.05 * np.sin(timepts)])
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4