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!