how to select time which comes in a range from cell array
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Elysi Cochin
am 25 Feb. 2017
Kommentiert: Walter Roberson
am 26 Feb. 2017
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
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 25 Feb. 2017
Bearbeitet: Walter Roberson
am 26 Feb. 2017
Convert to datetime objects and then use
4 Kommentare
Guillaume
am 25 Feb. 2017
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
am 26 Feb. 2017
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)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Dates and Time finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!