- Compute the fraction in each interval to determine the end value wanted, then
- Use that function as the target for retime to reset the time vector.
How can I change time data to 5-minutes intervals?
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
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
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Timetables 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!