Object-Oriented Implementation

The main data structures in Control System Professional, TransferFunction and StateSpace, represent transfer-function and state-space objects. They are what may be called "active wrappers," meaning that they act as containers that keep all the relevant information about the system together and they convert between the data structures when applied over each other. Here, the relevant information is the matrix describing the input-output relations (possibly with a formal variable), or a collection of matrices describing a state-space realization of the system, the domain (continuous-time or discrete-time), and possibly a sampling period or sampling rate used to discretize the system and other information.

As an example, after loading the application,

[Graphics:Images/index_gr_1.gif]

we consider a third-order system.

[Graphics:Images/index_gr_2.gif]
[Graphics:Images/index_gr_3.gif]

Note that the scalar SISO (single-input, single-output) function is automatically "upgraded" to a MIMO (multi-input, multi-output) transfer matrix, which is a standard way to represent input-output relations in the application. To find a state-space realization of the transfer-function object, we apply the StateSpace head.

[Graphics:Images/index_gr_4.gif]
[Graphics:Images/index_gr_5.gif]

We can review the state-space and transfer-function objects in the traditional matrix notation.

[Graphics:Images/index_gr_6.gif]
"A" [Graphics:Images/index_gr_7.gif]
"B" [Graphics:Images/index_gr_8.gif]
"C" [Graphics:Images/index_gr_9.gif]

To recover the transfer-function representation, we simply apply the TransferFunction head.

[Graphics:Images/index_gr_10.gif]
[Graphics:Images/index_gr_11.gif]

Notice that the formal variable in transfer-function objects is optional. When it is not supplied, the standard Mathematica convention for pure functions is used and the formal variable is denoted as #. TransferFunction further resembles Function in that it can be applied to any variable. For example, here is the transfer matrix in the variable s.

[Graphics:Images/index_gr_12.gif]
[Graphics:Images/index_gr_13.gif]

We can use the same mechanism to obtain the value of the transfer matrix at a particular frequency ω.

[Graphics:Images/index_gr_14.gif]
[Graphics:Images/index_gr_15.gif]

This system is assumed to be in the continuous-time domain (that is, it represents the analog system). The function ToDiscreteTime finds the discrete-time approximation. The library of sampling methods can be accessed by choosing the value of the option Method, which currently supports such transforms as ZeroOrderHold, FirstOrderHold, ForwardRectangularRule, BackwardRectangularRule, BilinearTransform, ZeroPoleMapping, and BilinearTransform (which implements the bilinear, or Tustin, transform, with and without prewarping). Here is an example of such a conversion.

[Graphics:Images/index_gr_16.gif]
[Graphics:Images/index_gr_17.gif]

The option Sampled specifies the sampling period. It can also be set to True, to indicate a discrete-time system without giving a particular sampling period, or to False, for a continuous-time system. The default value is given by the global variable $Sampled, which is initially set to False.

One of the benefits of the object-oriented approach is that the same functions can operate on both transfer-function objects and state-space objects. For example, ToDiscreteTime can also be used to discretize the state-space object.

[Graphics:Images/index_gr_18.gif]
[Graphics:Images/index_gr_19.gif]

The function ToContinuousTime converts the system back to the continuous-time domain.

[Graphics:Images/index_gr_20.gif]
[Graphics:Images/index_gr_21.gif]

Similarly, the same functions operate on both continuous-time and discrete-time systems. The user can easily implement the same functionality when extending the application. For example, suppose we want to compute the impulse response via the inverse Laplace or Z-transform (for transfer functions defined on the s- or z-plane, respectively), bypassing the built-in routines that use the state-space approach. With the functions InverseLaplaceTransform and InverseZTransform, from the standard packages Calculus`LaplaceTransform` and DiscreteMath`ZTransform`, it is easy to build a function that behaves like the built-in functions.

[Graphics:Images/index_gr_22.gif]
[Graphics:Images/index_gr_23.gif]

Using the Control System Professional function ContinuousTimeQ (which tests whether the system is in the continuous-time domain), the new function automatically selects the appropriate transform and applies it to all elements of the transfer matrix. The options, if any, are passed to the transform. For the discrete-time transfer function

[Graphics:Images/index_gr_24.gif]

the corresponding impulse response is

[Graphics:Images/index_gr_25.gif]
[Graphics:Images/index_gr_26.gif]