plot response of a system to a given input
ResponsePlot (sys, input, opts)
System; system object to simulate
algebraic, list(algebraic), Vector(realcons), or list(Vector(realcons)); input signal to the system
(optional) equation(s) of the form option = value; specify options for the ResponsePlot command
Some options are used only with particular types of systems. If an option is not usable, it is ignored.
initialconditions = Vector(realcons) or list of equations
Specifies the initial conditions of the system. For a state-space system the initial conditions are specified as a Vector with dimension equal to the number of state-variables. For a differential-equation system the initial conditions are a list of equations. For transfer-function, coefficients, zero-pole-gain, and difference-equation (discrete DE) systems, initial conditions are ignored. Ignored initial conditions are equivalent to initial conditions of zero.
output = algebraic, list(algebraic), or listlist(algebraic)
Specifies the expressions to plot.
A single algebraic expression generates a plot of the expression versus time. The names of the system variables in the expression are replaced with their values at each instant of the solution. For example, for a continuous system with y1 as an output variable and x1 as a state variable, the expression t*x1*y1^2 plots t⁢x1⁡t⁢y1⁡t2 versus t.
A list(algebraic) expression generates a multiplot of each element in the list versus time. The names of the system variables in the elements are replaced with their values at each instant of the solution. For example, for a discrete system with y1 and y2 as an output variables and u1 as an input variable, the list [y1, y2/u1] plots y1(q) versus q and y2(q)/u1(q) versus q.
A listlist(algebraic) expression generates a parametric multiplot, with each sublist specifying the coordinates of the corresponding plot. If the sublists contain two elements, then the plots are 2-D plane curves. If the sublists contain three elements, then the plots are 3-D space curves. The names of the system variables in the elements are replaced with their values at each instant of the solution. For example, for a continuous system with y1 and y2 as output variables, the listlist [[y1, y2]] plots y1⁡t versus y2⁡t.
As described above, system variables are substituted for the corresponding names in the expressions. Continuous systems do not have access to the input variables, while discrete systems do.
The default is to plot all output variables of a system versus time.
parameters = set(name = complexcons) or list(name = complexcons)
Specifies numeric values for parameters in sys. These values override those specified by the parameters field of the system object, which in turn override the settings in in SystemOptions(parameters). The numeric value on the right-hand side of each equation is substituted for the name on the left-hand side in the expressions that define the model. No checking is done during the substitution to determine whether the substituted value is valid. For example, a complex value can be substituted for the coefficient of a polynomial. If the complex value had been originally assigned to the model at creation, a warning would be generated.
Continuous System Options
dsolveargs = list( equation )
Specifies extra parameters to be passed to dsolve. The simulation is achieved by formulating the system as a set of differential equations and then passing them to dsolve. With this option additional parameters can be passed to dsolve. See dsolve/numeric/DAE for details.
duration = realcons
Specifies the duration of the simulation. The simulation starts at t=0 and proceeds until t = duration. The default value is assigned by DynamicSystems[SystemOptions].
The ResponsePlot command plots the time response of sys, a System object, to a given input.
ResponsePlot uses DynamicSystems[Simulate] to generate the response, consequently, sys and input must be compatible with Simulate.
The ResponsePlot command takes all standard plot,options.
Create a linear system from a differential equation.
deqs ≔ 0.5⁢ⅆⅆt⁢i⁡t+i⁡t=v⁡t−0.01⁢ⅆⅆt⁢θ⁡t,0.01⁢ⅆⅆt⁢ⅆⅆt⁢θ⁡t+0.1⁢ⅆⅆt⁢θ⁡t=0.01⁢i⁡t
sys ≔ DiffEquation⁡deqs,inputvariable=v⁡t,outputvariable=θ⁡t,i⁡t:
Generate the input waveform, a sine wave with amplitude 1 and natural frequency of 2 radian/second.
vin ≔ Sine⁡1,2
Plot the response of the system to the input for a simulation time of 10 seconds. This is the command to create the 2-D plot from the Plotting Guide.
Tsim ≔ 10:
Plot theta vs i as time varies over the duration.
Create a discrete simulation of the previous system. Convert sys to a sampled system with a sampling period, Ts, of 0.1 second. Assign the default samplecount so that the duration corresponds to Tsim'.
Ts ≔ 0.1:
sysz ≔ ToDiscrete⁡sys
sysz≔Diff. Equationdiscrete; sampletime = .12 output(s); 1 input(s)inputvariable=v⁡qoutputvariable=θ⁡q,i⁡q
vin_z ≔ Sine⁡1,2,discrete=true
Plot the response of the system, and the input.
Plot the output state, versus time, as a space-curve. This is the command to create the 3-D plot from the Plotting Guide.
If the time-constants of the system are much less than the duration, passing the dsolve option stiff to PlotResponse can improve the plot. For example
sys ≔ TransferFunction⁡w02s2+2⁢zeta⁢w0⁢s+w02,parameters=w0=1T,zeta=34:
T ≔ 10−6:
Download Help Document
What kind of issue would you like to report? (Optional)