round_datenum

Rounds matlab datenum time to a multiple value of a time unit.
2 Downloads
Updated 10 Nov 2023

View License

Rounds matlab datenum time to a multiple value of a time unit.
Have you ever wanted to grid a dataset on, say, a 15 minute grid, and want the time to start at the nearest 15 minute interval from the top of the hour? This is the script for you!
For time = datenum(2023,11,10,18,23,47), round_datenum(time,'minute',15,'ceil') returns datenum(2023,11,10,18,30,00)
Handles rounding year, month, day in year, hour, minute, and second
Can specify to round to the nearest value, or in a set direction
Only workes for single datenum time inputs

Cite As

Alexander Andriatis (2026). round_datenum (https://www.mathworks.com/matlabcentral/fileexchange/154890-round_datenum), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2023b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags
Version Published Release Notes
1.0.0