Transfer Functions in Simulink: Dynamical Systems, Filtering and State Machines

Bahadir
4 min readOct 8, 2019

--

In this article I will try to bring Mealy & Moore State Machines, Transfer Functions and Differential Equations together by means of Simulink applications.

In Simulink dynamical systems are represented as transfer functions. You will recognize the term s from Laplace transformation.

First of all, all of the initial value differential equations in time domain has corresponding Laplace equations. But only some of them can be represented in terms of transfer functions. It is “some” because in order to convert Laplace equations into transfer functions, you need to be able to divide output by the input in Laplace domain and obtain the transfer function of the system. And for this division to be clear you need special initial conditions.

Determining the numerator and denominator arrays you simply create transfer functions for let’s say Low Pass Filters or High Pass Filters. You will also observe that 1/s is the time integration of a signal.

If you ever tried to test different transfer functions’ responses to step input, or constant input or whatever, you would realize that first output (response) value at t=0 is highly dependent on input at t=0 for cases where numerator and denominator have the same order, while the first value of the output is always zero for the rest. The underlying reason of this behavior is Mealy & Moore State Machine concepts.

Let’s do some paper work

Take 2 simple examples: 1st order low pass filter and 1st order high pass filter.

1st Order LPF & HPF

In the first case, low pass filter, the input-output equation is

If the initial value of y(t) was not zero, then we would struggle with the impulse function, therefore Simulink simply omits that case. From this step on, according to the given discrete solver, Simulink solves this differential equation by using current value at each step, but gives the result at the next step (since the output of the current step is already known). That means, the response of the system, at a specific time, is independent of the input value at that time, which is the behavior of Moore Machines.

In the second case, high pass filter, we have

As you see there are no assumptions made on output, but Simulink introduced a new intermediate variable k(t), in order to prevent numerical differentiation of input signal x(t). Let’s go further for the new variable.

The intermediate variable k(t) has now assumption on it, just like in low pass filter example. Thus, instead of solving for the main response, Simulink numerical solver this time works for intermediate variable k(t), and uses its value together with the input value in order to find the response at given time. That is, given the time, the output of this filter is dependent of the input value at that time, which is the behavior of Mealy Machines.

Simulink avoids numerical differentiation

Theoretically speaking, you don’t need to apply polynomial division to the transfer functions. Having s terms just before X(s) still makes sense and you could this time make initial value assumption of output combined with the exact initial input value. However, after inverse laplace operator, having derivatives of input signal will introduce more numerical errors apart from the error from the solver.

For higher order transfer functions, if you transform the filter into its corresponding differential equation, and then implement the numerical solver by hand, and later compare the results with Simulink, you will see that Simulink introduces many intermediate variables when it applies polynomial division to the transfer function, then removes all s terms from numerator in order to prevent numerical differentiation on input x(t).

--

--

Bahadir

Mathematician. Software Engineer. PhD Student at Maths. 12+ Years Experience in Software.