- 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?
4 ビュー (過去 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 で Data Import and Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!