Organizing and calculating with timestamps and numbers.

7 ビュー (過去 30 日間)
Neko Benítez
Neko Benítez 2019 年 10 月 8 日
編集済み: Stephen23 2019 年 10 月 9 日
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 件のコメント
John Doe
John Doe 2019 年 10 月 9 日
Did my suggestions work for you?

サインインしてコメントする。

採用された回答

John Doe
John Doe 2019 年 10 月 8 日
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
  2 件のコメント
Neko Benítez
Neko Benítez 2019 年 10 月 9 日
Thank you very much, John. I checked, and it worked. I have to check the advantages of using timetable instead of just a table. As I said, I need to group data for each hour, day, and so on. Once I have all the time data in column 1 of the table, do you suggest any precise way to group the matching data for hours, days and so on?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by