I was going to do the recursive least square algorithm in Xcos but I having some trouble to find the second derivative. The results of the second derivative differ a lot depending which solver I use.

First of all, I want to compute the $y(t)$ output of this transfer function:

$$G(s) = \frac{Y(s)}{U(s)} = \frac{K}{as^2 + bs + 1}$$


$$Y(s)[as^2 + bs + 1] = U(s)[K]$$ $$Y(s)as^2 + Y(s)bs + Y(s)1 = U(s)K$$ $$ay''(t) + by'(t) + y(t) = Ku(t)$$ $$y(t) = Ku(t) - ay''(t) - by'(t)$$

Unknows are: $K$, $a$ and $b$

But let's assume that I know them. Then I set up this simulation.

enter image description here

Where $K=5$, $a=2$, $b=3$. I use Runge-Kutta 4(5).

The result is:

Where the green line is $y(t)$ (transfer function output) and black is the computed $y(t)$.

enter image description here

Not successful at all. I change to Dormand-Prince 4(5). The result is:

enter image description here

I use Implicit Runge-Kutta 4(5) enter image description here


Which solver should I use?

It works if I do this in OpenModelica. But the problem is that OpenModelica is not for control engineering, only simulation of dynamical systems using dynamical blocks of complete blocks.

up vote 0 down vote accepted

Here is the answer.

I choose Runge-Kutta 4(5) with this setup:

enter image description here

Change the du/dt block to s-laplace block.

enter image description here

And the result is:

enter image description here

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.