In the table below you can find the equivalent between the Simulink® and Xcos blocks for Continuous time library/palette. The block which are not present in both libraries are omitted from the table.
This conversion table can be used in case you need to convert a Simulink® model to an Xcos block diagram model or vice-versa.
Let’s look at a simple example in which we create a Simulink® block diagram model, simulate it and plot the results. We’ll recreate the equivalent model in Xcos and check if the results are the same.
Simulink® block diagram model
The purpose of the model is only to use some of the Continuous time Simulink® blocks which have an equivalent in the Xcos palette.
The transfer function is defined as:
\[H(s) = \frac{s+0.1}{2s^2 + 0.5s +1}\]Writing the coefficients of the transfer function polynomials as arrays, we can use the embedded Matlab function tf2ss()
to calculate the A
, B
, C
and D
matrices for the state-space model.
num = [1 0.1]; den = [2 0.5 1]; [A,B,C,D] = tf2ss(num,den)
The step input has an amplitude of 1
starting at time equals 1 s
. All the other blocks have default parameters. Also, the simulation parameters are set on default values.
By running the Simulink® model above, we get the following plot window:
Xcos block diagram model
We follow the same approach for the Xcos block diagram model. Using equivalent blocks (see table above), we recreate the same functionality of the Simulink model.
In order to get the A
, B
, C
and D
matrices for the state-space model of the transfer function, we use the embedded Scilab function tf2ss()
(which is equivalent with the Matlab one).
s=poly(0,'s'); H=[(s+0.1)/(2*s^2+0.5*s+1)]; Sys=tf2ss(H) A=Sys(2); B=Sys(3); C=Sys(4); D=Sys(5);
The step function has the same parameters as the Simulink one. All other Xcos blocks have the default parameters , except the Variable delay
block which must have the Max delay
parameter higher or equal to 3
.
After running the Xcos model for 10 s
, we get the following graphical window:
As you can see, the outputs of the Xcos block diagram model are identical with the Simulink results. This proves that we can use Xcos as an alternative to Simulink, when we want to simulate and analyze continuous time models.
For any questions, observations and queries regarding this article, use the comment form below.
Don’t forget to Like, Share and Subscribe!