how to select time which comes in a range from cell array

1 次查看(过去 30 天)
if i have a time as
cellArr = {'6:25:48'
'7:28:18'
'8:30:20'
'9:32:37'
'10:35:40'};
how to select time which comes in a range? eg: time between 7:00:00 and 9:00:00
7:28:18
8:30:20

采纳的回答

Walter Roberson
Walter Roberson 2017-2-25
编辑:Walter Roberson 2017-2-26
Convert to datetime objects and then use
  4 个评论
Guillaume
Guillaume 2017-2-25
You may have written your comment as I edited mine. Use the 'Format' property of the datetime object to make it display as you want.
t = datetime(cellArr, 'Format', 'hh:mm:ss')
Walter Roberson
Walter Roberson 2017-2-26
You also might want to consider using duration objects:
cellArr = {'6:25:48'
'7:28:18'
'8:30:20'
'9:32:37'
'10:35:40'};
temp = regexp(cellArr, ':', 'split');
durations = duration(str2double(vertcat(temp{:})));
low = hours(7);
high = hours(9);
durations(durations >= low & durations <= high)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Dates and Time 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by