Calendar duration in days
D = caldays( returns
an array representing calendar days equivalent to the values in array
Xis a numeric array, then
calendarDurationarray with each element equal to the number of calendar days in the corresponding element of
X. Calendar days account for Daylight Saving Time shifts when used in calendar calculations.
doublearray with each element equal to the number of whole calendar days in the corresponding element of
Create Array of Calendar Days
X = magic(5); D = caldays(X)
D = 5x5 calendarDuration 17d 24d 1d 8d 15d 23d 5d 7d 14d 16d 4d 6d 13d 20d 22d 10d 12d 19d 21d 3d 11d 18d 25d 2d 9d
Convert Calendar Durations to Calendar Days
Create an array of calendar durations. Then, convert each value to the equivalent number of whole calendar days.
X = caldays(8:10) + hours(1.2345)
X = 1x3 calendarDuration 8d 1h 14m 4.2s 9d 1h 14m 4.2s 10d 1h 14m 4.2s
D = caldays(X)
D = 1×3 8 9 10
caldays returns a numeric array.
Current Time at Future Date
Add two calendar days to the current date and time.
t = datetime('now') + caldays(2)
t = datetime 03-Sep-2021 10:20:56
Create Sequence of Dates
Create a sequence of consecutive dates beginning on March 18, 2014.
T = datetime([2014,03,18]) + caldays(0:4)
T = 1x5 datetime 18-Mar-2014 19-Mar-2014 20-Mar-2014 21-Mar-2014 22-Mar-2014
Create a sequence of dates beginning on March 18, 2014, spaced 2 days apart.
T = datetime([2014,03,18]) + caldays(0:2:8)
T = 1x5 datetime 18-Mar-2014 20-Mar-2014 22-Mar-2014 24-Mar-2014 26-Mar-2014
caldayscreates days that account for Daylight Saving Time shifts when used in calendar calculations. To create exact fixed-length (24 hour) days, use the
Calculate with arrays that have more rows than fit in memory.
This function fully supports tall arrays. For more information, see Tall Arrays.
Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.
This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).