필터 지우기
필터 지우기

How can I change time data to 5-minutes intervals?

조회 수: 3 (최근 30일)
Wolfgang McCormack
Wolfgang McCormack 2020년 8월 27일
편집: VBBV 2020년 9월 8일
Hello everyone, how can I change time intervals of a binary data (0 and 1) to 5-minutes intervals? [for 5 minutes periods that include both 0 or 1, I want to have the value that has occupied more than 50% of the period; for instance, if 1 was in 10:10 to 10:15 for 3 minutes, then the interval includes the value 1 ]
Here is an example: I have the following time and data
Column 1 Column 2
Aug 27 8:35:37 1
Aug 27 9:47:00 0
Aug 27 9:49:59 1
Aug 27 9:54:50 0
Aug 27 10:35:45 1
I want this data to turn to 5 minutes intervals like this:
Column 1 Column 2
Aug 27 8:35:00 1
Aug 27 8:40:00 1
Aug 27 8:45:00 1
.....
Aug 27 9:45:00 1
Aug 27 9:50:00 0 (Because about 3 minutes in this interval (from 9:45 to 9:50 ) was 0)
Aug 27 9:55:00 1 (because about 4 minutes was 1)
Aug 27 10:00:00 0
Aug 27 10:05:50 0
....
Aug 27 10:35:00 1
Aug 27 10:40:00 1
I am new to Matlab so I really appreciate it if you could provide the code. Thank you in advance!
  댓글 수: 3
Wolfgang McCormack
Wolfgang McCormack 2020년 8월 27일
@dpb thank you very much. Yes, the data is imported from excel as a timetable. To be honest, I don't know how to compute the fraction in each interval because at the moment there is no interval. It has recorded the data using a sensor. So, a 0 might be at 10:00 and another in 11:47 or the next at 11:48. I guess I should be able to do that from here> https://www.mathworks.com/help/fixedpoint/ref/fixed.interval.html , is that what you meant for the first step?
VBBV
VBBV 2020년 9월 8일
편집: VBBV 2020년 9월 8일
Import the timestamp sensor data from excel to a vector,say T
%
%if true
% end
T = [1:00:00 2:00:00 3:00:00...];
D = T(1):minutes(5):T(end);
% creates a vector D with a 5 minute interval data of vector T
Then use the if condition within a loop to assign the binary values to the intervals in the D vector

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

채택된 답변

VBBV
VBBV 2020년 9월 4일
편집: VBBV 2020년 9월 7일
Import the timestamp sensor data from excel to a vector,say T
%
%if true
% end
T = [1:00:00 2:00:00 3:00:00...];
D = T(1):minutes(5):T(end);
% creates a vector D with a 5 minute interval data of vector T
Then use the if condition within a for loop to assign the binary values to the intervals

추가 답변 (0개)

카테고리

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

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by