Legacy Documentation

Control System Professional (1995)

This is documentation for an obsolete product.
Current products and services

 Documentation /  Control Systems Professional /  Time-Domain Response /

Symbolic ApproachStep, Impulse, and Other Responses

4.2 Simulating System Behavior

Once input signals are supplied to StateResponse or OutputResponse in the form of a function in the specified variable, as described in Section 4.1, a symbolic solution based on Eq. (4.2) or Eq. (4.5) is attempted. There are, however, situations when the symbolic solution is either impossible or just too time consuming. In such cases, StateResponse and OutputResponse can be used to carry out a simulation of the state and output responses. For continuous-time systems, the simulation is based on the approximate numerical solution of the underlying differential equations using the built-in function NDSolve and is invoked when the range for the time-domain variable in the form of {t, 0, tmax}, or simply {t, tmax}, is given instead of the variable t. The result then appears in terms of InterpolatingFunction objects. This regime is referred to as the analog simulation.

For discrete-time systems, the same input syntax causes the input functions to be sampled on a uniform time grid. The grid starts at time (or ). The discrete simulation then proceeds in a straightforward manner according to Eq. (4.4) starting from the initial conditions for and then iterating for . Instead of supplying the input functions and the range for the time variable, you can give the input sequences explicitly. Note that if you supply the input signals in the form of input sequences for the continuous-time system, the system is first converted to discrete time, and then the simulation is performed. To facilitate the conversion, the response functions accept the options pertinent to ToDiscreteTime, notably Sampled may be used to set the sampling period, and Method to choose the conversion method.

When input signals are discretized, the input sequences u must represent a matrix each row of which corresponds to a signal at one input, and the number of rows must be equal to the number of inputs. For single-input systems, the matrix may be reduced to a vector.

State and output responses in the simulation mode.

Let us simulate the output of the T-bridge network in Figure 4.2 to a square-wave signal.

Figure 4.2. A T-bridge.

This is the transfer function for the T-bridge network.

In[18]:=

Out[18]=

Here is the transfer function for a given set of parameters.

In[19]:=

Out[19]=

This utility function creates a square wave with period Tau.

In[20]:=

Supplying the input signal together with both the time variable and the duration of time period causes OutputResponse to perform in the simulation mode. The output is a list of simulated responses. In this case, there is only one element in the list since we are dealing with a single-output system.

In[21]:=

Out[21]=

This plots the input (the solid line) and the output (the dashed line) signals.

In[22]:=

This produces the output of the circuit using the discrete simulation with the sampling period Tau. Note that the sampling period is supplied to OutputResponse to specify the distance between points in the input vector (produced by the Table function); this is necessary to convert the system to discrete time properly. The output is a list of simulated responses. In this case, there is only one vector in the list.

In[23]:=

In[24]:=

Out[24]=

The result can be drawn with the built-in Mathematica function ListPlot (MultipleListPlot for multiple outputs). Here, however, we use a utility function, SimulationPlot, described later in this section.

In[25]:=

This compares the results of the analog and discrete simulations. Clearly, the chosen sampling period is too large to accurately approximate the behavior of the circuit.

In[26]:=

Output response simulation plots.

SimulationPlot provides a convenient way to compute and plot the output response of a system with a single function call. The syntax for SimulationPlot closely resembles the one for OutputResponse. As with OutputResponse, SimulationPlot produces the analog or discrete simulation depending on the type of input system, unless the input signal is specifically given as input sequences, in which case the discrete simulation takes place. You can also force the discrete simulation of a continuous system by giving the option Sampled to SimulationPlot. The option is ignored if the input signal is already sampled. For the purpose of simulation, the sampling period cannot take symbolic values.

As an exception, simulation of the response of continuous-time systems to the Dirac delta function is always performed in the discrete-simulation mode. To carry out analog simulation, you can mimic the Dirac delta function with a continuous impulse of small width. See the impulse response examples in Section 4.3. Note that, for a continuous-time system, the impulse response is simulated as a decay of some initial state conditions in the absence of the input signal. The initial conditions are determined by the components of the matrix .

To facilitate computation of the output response and conversion to discrete-time, if necessary, SimulationPlot takes the options for OutputResponse and ToDiscreteTime. Additionally, SimulationPlot accepts the options for the built-in plotting functions Plot, ListPlot, or MultipleListPlot and routes the options to appropriate functions.

This is an analog simulation of the output response of the bridge circuit to a square-wave input signal for another set of parameters of the bridge.

In[27]:=

This is a discrete simulation for the same parameters. The input system is discretized using the specified sampling period.

In[28]:=

This is a square pulse function.

In[29]:=

Out[29]=

This simulates the behavior of the bridge for yet another set of parameters. To ensure the correct result of NDSolve, which is called internally to compute the output response, we limit the value of MaxRelativeStepSize.

In[30]:=

This converts a particular bridge circuit to the discrete-time domain.

In[31]:=

Out[31]=

Here is the response of this circuit to random noise. Note that SimulationPlot picks up the sampling period from the input system.

In[32]:=

Although SimulationPlot generates only output response curves, it is a simple matter to get it to plot the state response as well. This can be done by adding an appropriate matrix to the StateSpace object composed of only matrices and . In the rest of the section we give an example.

Let us consider the linearized state-space system for the depth control problem of a submarine (see Figure 4.3) for small angles and constant velocity  ft/s as described in Dorf (1992). We will assume that the state variables are , and , where is the angle of attack and the input variable is , the deflection of the stern plane. We will compute the state response of the system to a step command for the stern plane of from zero initial conditions using the discrete-time approximation with sampling period  seconds.

Figure 4.3. Depth control of a submarine.

Here is the two-matrix state-space model.

In[33]:=

Out[33]=

To compute the state response, we insert a diagonal matrix containing some weighting coefficients.

In[34]:=

Out[34]=

This finds the discrete-time approximation of the system.

In[35]:=

Out[35]=

This plots the state response. We numericalize the input function to avoid supplying Degree (°) in symbolic form. Note that SimulationPlot automatically picks up as many points as needed for the discrete simulation to cover the specified time frame.

In[36]:=

Symbolic ApproachStep, Impulse, and Other Responses