control.nlsys

control.nlsys(updfcn,outfcn=None,**kwargs)[source]

Create a nonlinear input/output system.

Creates anInputOutputSystem for a nonlinear system by specifying astate update function and an output function. The new system can be acontinuous or discrete-time system.

Parameters
updfcncallable (orStateSpace)

Function returning the state update function

updfcn(t,x,u,params)->array

wherex is a 1-D array with shape (nstates,),u is a 1-D arraywith shape (ninputs,),t is a float representing the currenttime, andparams is a dict containing the values of parametersused by the function.

If aStateSpace system is passed as the update function,then a nonlinear I/O system is created that implements the lineardynamics of the state space system.

outfcncallable

Function returning the output at the given state

outfcn(t,x,u,params)->array

where the arguments are the same as forupdfcn.

inputsint, list of str or None, optional

Description of the system inputs. This can be given as an integercount or as a list of strings that name the individual signals.If an integer count is specified, the names of the signal will beof the form ‘s[i]’ (where ‘s’ is one of ‘u’, ‘y’, or ‘x’). Ifthis parameter is not given or given as None, the relevantquantity will be determined when possible based on otherinformation provided to functions using the system.

outputsint, list of str or None, optional

Description of the system outputs. Same format asinputs.

statesint, list of str, or None, optional

Description of the system states. Same format asinputs.

dttimebase, optional

The timebase for the system, used to specify whether the system isoperating in continuous or discrete time. It can have thefollowing values:

  • dt = 0: continuous-time system (default)

  • dt > 0: discrete-time system with sampling perioddt

  • dt = True: discrete time with unspecified sampling period

  • dt = None: no timebase specified

namestring, optional

System name (used for specifying signals). If unspecified, ageneric name ‘sys[id]’ is generated with a unique integer id.

paramsdict, optional

Parameter values for the system. Passed to the evaluation functionsfor the system as default values, overriding internal defaults.

Returns
sysNonlinearIOSystem

Nonlinear input/output system.

Other Parameters
input_prefix, output_prefix, state_prefixstring, optional

Set the prefix for input, output, and state signals. Defaults =‘u’, ‘y’, ‘x’.

See also

ss,tf

Examples

>>>defkincar_update(t,x,u,params):...l=params['l']# wheelbase...returnnp.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...])>>>>>>defkincar_output(t,x,u,params):...returnx[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)])