Defining Your Model

Once you have added sources to your model, you will likely want to define a model using continuous systems. There are a few methods available to define a model.

Transfer Function

This element can be used to define a transfer function by entering the numerator and denominator. For example, the following code

<transferFunction num="23" den="0.13 1"/>

represents this system


A special feature of the transfer function blocks on the qdex platform is that they are designed to accept both scalar and vector inputs. This means that, for example, you could pass several datasets through a single transfer function representing a low-pass filter and it will apply the filter to all of them. This approach, along with similar approaches taken with several of the other blocks available using the framework, allows authors to create systems with fewer blocks than would be conventionally required.

State Space

This element is similar to the transfer function block, in that you can define an arbitrary model, but in this case as a state-space model of the form


The block contains attributes for the requisite ABC, and D matrices. These matrices are defined in a similar manner to the transfer function attributes, for example:

<stateSpace name="pendulum"
       a="0 0 1 0; 0 0 0 1; 0 149 -15 5; 0 -262 14 -8.6" 
       b="0; 0; 0; 0" 
       c="0 0 0 0; 0 0 0 0; 0 0 0 0; 0 0 0 0"
       d="0; 0; 0; 0"/>

creates a state space model that represents a rotary pendulum.


The system block can be used to create a completely custom system by first identifying the number of states, and then the input and output widths. Finally, you can define the value(s) that are used by the solver to calculate the derivatives and outputs of the system.

<system name="mycustom" states="1">
  <input name="u" width="1"/>
  <output name="y" width="1"/>
    return states + u[1];
    return vector({3 * math.sin(2 * math.pi * time) + states[1] - u[1]});

When the solver is called at each time-step of the simulation, it triggers the onDerivatives event, which is responsible for providing the value(s) that are used by the solver to calculate the derivative of the state(s). It also calls the onOutputs event which uses Lua script to calculate the output at each time step. In this manner, you can create arbitrary linear or non-linear system definition.