split
Split calendar duration into numeric and duration units
Description
Examples
Split Calendar Duration Array
Create a calendarDuration
array.
T = calmonths(15:17) + caldays(8) + hours(1.2345)
T = 1x3 calendarDuration
1y 3mo 8d 1h 14m 4.2s 1y 4mo 8d 1h 14m 4.2s 1y 5mo 8d 1h 14m 4.2s
Get the month, day, and time.
[m,d,t] = split(T,{'months','days','time'})
m = 1×3
15 16 17
d = 1×3
8 8 8
t = 1x3 duration
01:14:04 01:14:04 01:14:04
Get the year, month, day, and time.
[y,m,d,t] = split(T,{'years','months','days','time'})
y = 1×3
1 1 1
m = 1×3
3 4 5
d = 1×3
8 8 8
t = 1x3 duration
01:14:04 01:14:04 01:14:04
When you request both the year and month, split
carries over month values greater than 12 to the year value.
Input Arguments
t
— Input calendar duration
calendarDuration
array
Input calendar duration, specified as a
calendarDuration
array.
Data Types: calendarDuration
units
— Date and time units
character vector | cell array of character vectors | string array
Date and time units, specified as a character vector, a cell array of
character vectors, or a string array. Specify units
only when the first input argument is the
calendarDuration
array,
t
.
The units can be one or more of the values in the table.
Value | Units t Is Split
Into |
---|---|
'years' | years |
'quarters' | quarters |
'months' | months |
'weeks' | weeks |
'days' | days |
'time' | time, in the format hours:minutes:seconds |
You must specify date and time units from largest to
smallest. For example, {'years','months'}
is valid, but
{'months','years'}
is not.
Example: split(t,{'years','months','days'})
Data Types: char
| cell
| string
Output Arguments
X1,X2,...
— Output numeric and duration
values
arrays
Output numeric and duration
values, returned as arrays.
split
returns year, month, and day values in numeric
arrays and time values in duration
arrays.
Data Types: double
| duration
Extended Capabilities
Tall Arrays
Calculate with arrays that have more rows than fit in memory.
The
split
function fully supports tall arrays. For more information,
see Tall Arrays.
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
Distributed Arrays
Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.
Version History
Introduced in R2014b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)