1
votes

I was trying to design my own simple implementation of a discrete-time integrator in Simulink using the trapezoidal rule. This is the result of my efforts (consider I'm using 1 as time integration interval): Then, just to double check if I did everything right I compared the results with the standard Simulink discrete-time integrator block (configured to use Trapezoidal rule of course):

Everything runs fine when I let the step rise at time 1 (both the custom and default integrator blocks have 0 as initial condition):

while with the step rising at time 0 I got a difference between the two integrators block response:

  • custom block: @ Integral(t=0)=0.5; @ Integral(t=1)=1.5
  • default block: @ Integral(t=0)=0; @t=1 Integral(t=1)=1

I think this depends on my custom block integrating between t=0 and the initial condition = 0 (i.e. applying the trapezoidal rule between 0 and 1, therefore getting 0.5).

Which is the best way to fix this and make my custom block show the same behaviour as the default one also at zero time? Is there any parameter/setting I am missing?

Thank you!

1

1 Answers

3
votes

Note that the trapezoidal integrator only needs, and should only have, one unit delay. The correct implementation is shown in the image below.

Discrete Integrator

From the second image that you show in the question, the output of the library block is zero at time equal to zero. That's not the default behaviour (as shown above, and also as discussed in the Integration and Accumulation Methods subsection of the doc for the Discrete Time Integrator block).

Did you change the Initial Condition Settings from State to Output? If so, then the state in the custom implementation needs to be modified appropriately.