I want to generate a timestamp from the unix time, which is delivered by an external C-function in a MATLAB function block in a simulink project. I'm trying to round the double values for hours, minutes and seconds to the integer in front of the decimal point. However, the function always rounds to the nearest integer. So my hours round up after 30 minutes and my minutes round up after 30 seconds. I tried the floor() function already, but it leaves the value unaltered. I tried to set up the fimath()-function in the model explorer and at the beginning of the script, but I guess it only changes fixed point values? (duh)
I have no idea what else to try. Where is my mistake?
leftover_seconds = leftover_seconds - (sum_days + days - 1)*24*3600;
hours = leftover_seconds/3600;
minutes = (leftover_seconds - hours*3600)/60;
seconds = leftover_seconds - ((hours*3600) + (minutes*60));
I deleted the floor() functions in front of each line, because it didn't do anything.
I appreciate any tips. Thank you!