MATLAB: Fixed step discrete time is not really fixed in Simulink

discrete timefixed-stepfrom workspaceMATLABsimulink

Dear all,
I am experiencing some problems using a Simulink model with a fixed step discrete time solver (for example 0.01 seconds). The model simply consists of 2 blocks: one "From Workspace" block ("interpolate data" option not enabled), and one "To Workspace" block ("Save format" option set to "Structure with time"). If I run the simulation and I look to the time field of the data saved to workspace, I can see that the time step is not always fixed. It is sometimes lower or greater than 0.01 (sometimes 0.0099999999999, other times 0.010000000001). If I don't want to use the "interpolate data" option, this means that I get an output that it is different from input (i.e. I get some input samples repeated on output, and others that are skipped). The "funny" thing is that this behavior depends on the number of samples of the input variable.
Why am I getting this jitter on the time step? Shouldn't it be supposed to be fixed? Is there any option to force it to exactly what I set on the solver options tab?
Thank you for any help.
Kind regards,
Alberto

Best Answer

The Simulink blog has a post that describes this behavior in pretty good detail here.
Essentially the way the time vector is created in Simulink for the discrete solver may be different from the way your input data has created input time and there is a small error between the two.