Organizing and calculating with timestamps and numbers.
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Neko Benítez
el 8 de Oct. de 2019
I have a matrix, in which in the first column I have timestamps, usually one every 10 seconds, but it is not constant, and sometimes there are more than 10 seconds between one timestamp and another. The second column is power readings (numbers). A brief example would be something like this:
1570226408 1000022
1570226418 1000022
1570226431 1000022
1570226438 1000032
1570226448 1000032
1570226458 1000032
1570226469 1000032
I converted the timestamps into DateTime format, but the problem is that I can not have in the same matrix, two different classes (DateTime and double).
What I want to do is to be able to process that file, to calculate the total power per hour, per day, the energy for each hour or the total energy per day. Do you have any idea about how to do this?
PS. I managed to do this in a very rustic way: convert the timestamp into date number and work with the decimals of those date numbers to differentiate hours, but I reckon there should be a more efficient and straightforward way to do this.
1 comentario
Respuesta aceptada
John Doe
el 8 de Oct. de 2019
Create a table - a table can handle both datetime, double, single etc.
t = array2table(data)
You can then do your analysis as you please using datetime. To call a variable use:
t.VariableName
Timetable can also be used.
doc timetable
Más respuestas (0)
Ver también
Categorías
Más información sobre Dates and Time en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!