select data from table according to date and time

조회 수: 8 (최근 30일)
MOMO JOJO
MOMO JOJO 2019년 3월 26일
댓글: Peter Perkins 2022년 3월 2일
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
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?
MOMO JOJO
MOMO JOJO 2019년 3월 27일
Dear Walter,
The times are in the same table. Some of data are mentionned bellow. They are for 7 days
'08-Feb-2019 11:03:40'
'08-Feb-2019 11:08:40'
'08-Feb-2019 11:13:40'
'08-Feb-2019 11:18:40'
Thanks

댓글을 달려면 로그인하십시오.

답변 (1개)

Akira Agata
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
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 ?
Peter Perkins
Peter Perkins 2022년 3월 2일
Presumably you would modify my answer from 2-Apr-2019.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by