i have a problem with the rounding that MATLAB does (automatically). In my loop the time increases by 0.05 second each time, or if there is a special circumstance, it will add a time value in between. So in order to get the next value, i used
floor((t(n-1)/dt)*dt+dt
to calculate the next time value. Since floor((t(n-1)/dt) would calculate the amount of steps of 0.05 seconds so far, and it would it then multiply again with this timestep and add another step to get the next value. Even if the current time is not a multiple of 0.05, the next time step will be. Exactly what i wanted. However matlab does some rounding i do not understand, see the screenshot below. I even added a tolerance of 10^-14 to counter the roundings, but when the time becomes larger, the roundings will become larger than the tolerance.
As you can see in the screenshot, dividing 32.05 by 0.05 gives 640.9999999999999 instead of 641. And in my script this causes the loop to go on forever, since this is floored back to 640, meaning the time will never increase anymore and will stay at 32.05 at every loop.
*I need 10 reputation at least for an image, so here is a link: https://i.sstatic.net/6tNRC.jpg
Edit:
Is there any way to solve this issue?
Divakar gave me the hint towards the proper answer. it was solved by using
t(n) = floor((eps(t(n-1))+t(n-1))/dt)*dt+dt;
But most likely an alternative solution would be the suggestion of Mendi Barel, to convert the time to miliseconds so that all numbers are integers. Thank you all for the help and this question is solved now.