spacetime

Version 1.0.0 (2.12 KB) by Jakob Weis
spacetime creates an equally-spaced time vector between two points in time.
10 Downloads
Updated 9 Feb 2022

View License

SPACETIME(t_start,t_end,t_step,t_unit) creates an equally-spaced time vector between two points in time.
t0: Start time
tn: End time
ti: interval or number of time steps
t_unit: unit of time
Supported time step units:
Seconds - 'SEC' (integer or decimal)
Minutes - 'MIN' (integer or decimal)
Hours - 'HRS' (integer or decimal)
Days - 'DAY' (integer or decimal)
Weeks - 'WKS' (integer or decimal)
Months - 'MON' (integer)
Years - 'YRS' (integer)
n steps - 'STP' (integer indicating number of time steps)
Examples:
1) Bi-annual spacing:
t_out = SPACETIME(datetime('1950-09-01'),datetime('2022-09-01'),6,'MON')
t_out =
[01-Sep-1950
01-Mar-1951
01-Sep-1951
...
01-Sep-2021
01-Mar-2022
01-Sep-2022]
2) Minutely spacing:
t_out = SPACETIME([2022 2 9 12 0 0],[2022 2 9 18 0 0],5,'MIN')
t_out =
2022 2 9 12 0 0
2022 2 9 12 5 0
2022 2 9 12 10 0
... ... ... ... ... ...
2022 2 9 17 50 0
2022 2 9 17 55 0
2022 2 10 18 0 0
3) Specifying a number of time steps
t_out = SPACETIME(datestr(today),datestr(today+365),10,'STP')
t_out =
{'09-Feb-2022 00:00:00'}
{'21-Mar-2022 13:20:00'}
{'01-May-2022 02:40:00'}
{'10-Jun-2022 16:00:00'}
{'21-Jul-2022 05:20:00'}
{'30-Aug-2022 18:40:00'}
{'10-Oct-2022 08:00:00'}
{'19-Nov-2022 21:20:00'}
{'30-Dec-2022 10:40:00'}
{'09-Feb-2023 00:00:00'}
------------------------------------------------------------
Author Info
Jake Weis, Institute for Marine and Antarctic Studies (IMAS)
February 2022

Cite As

Jakob Weis (2024). spacetime (https://www.mathworks.com/matlabcentral/fileexchange/106410-spacetime), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2021b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0