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

9 visualizaciones (últimos 30 días)
Wolfgang McCormack
Wolfgang McCormack el 27 de Ag. de 2020
Editada: VBBV el 8 de Sept. de 2020
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 comentarios
Wolfgang McCormack
Wolfgang McCormack el 27 de Ag. de 2020
@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 el 8 de Sept. de 2020
Editada: VBBV el 8 de Sept. de 2020
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

Iniciar sesión para comentar.

Respuesta aceptada

VBBV
VBBV el 4 de Sept. de 2020
Editada: VBBV el 7 de Sept. de 2020
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

Más respuestas (0)

Categorías

Más información sobre Timetables en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by