MATLAB: Continuous integrator vs discrete-time integrator

discrete-time integratorsimulink

Hello.
I'm trying to convert the simulink model with continuous system to discrete system.
I replaced integrator block with discrete-time integrator block.
However the results showed different values and I can not figure out what is the problem of different results.
In the figure, x1 always return 0 regardless of the input constant.

Best Answer

What you observe is expected. Different blocks... different results ;-)
Use Scope blocks to understand the evolution.
As you probably know, the continuous version of this set of equation is marginally stable... which means it will oscillates forever. If you connect a Scope to the continuous version, this is what you will observe.
For the discrete, by defaul, the sample time of the DTI is 1s. This makes the system unstable. By default, the simulation stop time of a model is 10 seconds. With a scope, you will see that after going up and down you are very lucky that the values on your display are 1 and 0. If you simulate a bit longer, you will see that the oscillation slowly diverges.