MATLAB 帮助中心
将日历持续时间拆分为数值和持续时间单位
[X1,X2,...] = split(t,units)
[X1,X2,...] = split(t,units) 以单独的数值数组形式返回 t 中指定的日历持续时间值,其各个元素分别对应于 units 所指定的各个日期或时间单位。units 指定的日期和时间单位的数目确定输出参量的数目。
X1,X2,...
t
units
示例
全部折叠
创建一个 calendarDuration 数组。
calendarDuration
T = calmonths(15:17) + caldays(8) + hours(1.2345)
T = 1×3 calendarDuration 1y 3mo 8d 1h 14m 4.2s 1y 4mo 8d 1h 14m 4.2s 1y 5mo 8d 1h 14m 4.2s
获取月、日和时间。
[m,d,t] = split(T,{'months','days','time'})
m = 1×3 15 16 17
d = 1×3 8 8 8
t = 1×3 duration 01:14:04 01:14:04 01:14:04
获取年、月、日和时间。
[y,m,d,t] = split(T,{'years','months','days','time'})
y = 1×3 1 1 1
m = 1×3 3 4 5
当同时请求年和月份时,split 会将大于 12 的月份值进位到年值。
split
输入日历持续时间,指定为 calendarDuration 数组。
数据类型: calendarDuration
日期和时间单位,指定为一个字符向量、字符向量元胞数组或字符串数组。仅当第一个输入参量为 calendarDuration 数组 t 时才指定 units。
单位可以是下表中的一个或多个值。
'years'
'quarters'
'months'
'weeks'
'days'
'time'
必须从最大到最小指定日期和时间单位。例如,{'years','months'} 有效,但 {'months','years'} 无效。
{'years','months'}
{'months','years'}
示例: split(t,{'years','months','days'})
split(t,{'years','months','days'})
数据类型: char | cell | string
char
cell
string
duration
输出数值和 duration 值,以数组的形式返回。split 在数值数组中返回年、月、日值,在 duration 数组中返回时间值。
数据类型: double | duration
double
全部展开
split 函数完全支持 tall 数组。有关详细信息,请参阅 tall 数组。
backgroundPool
ThreadPool
在 R2014b 中推出
time | calyears | calquarters | calmonths | calweeks | caldays
time
calyears
calquarters
calmonths
calweeks
caldays
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.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
欧洲
亚太
联系您当地的办事处