select data from table according to date and time
9 次查看(过去 30 天)
显示 更早的评论
Hallo,
I need your help for matlab.
I have a table with dates and times data for 7 days. I want to select records between 14:00 to 16:00 for each day?!
Thanks
2 个评论
Walter Roberson
2019-3-26
Are the times in a separate variable in the table, or do you have a single datetime column?
If the times are in a separate variable in the table, then what format are they in?
回答(1 个)
Akira Agata
2019-3-27
How about the following way?
% Create sample data
Time = sort(datetime(2019,3,24) + days(7)*rand(1000,1));
Data = rand(1000,1);
T1 = table(Time,Data);
% Select records (row index) between 14:00 to 16:00
idx = (T1.Time.Hour >= 14) & (T1.Time.Hour) < 16;
% Extract selected records
T2 = T1(idx,:);
8 个评论
pruth
2022-2-21
hello,
what if i want to select minutes along with an hour. ? data between 14:30 and 15:30 ? how do i do it ?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!