Organizing and calculating with timestamps and numbers.
7 ビュー (過去 30 日間)
古いコメントを表示
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.
採用された回答
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
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Dates and Time についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!