How to find the successive difference between timestamps in hours?

1 次查看(过去 30 天)
The attachment has 1138 samples of datenum format.I want to find the sum of total hours in this order of index (2-1)+(4-3)+(6-5)+.....+(1138-1137). Any suggestions. The answer comes around 200 hours.

采纳的回答

Guillaume
Guillaume 2018-6-18
d = datetime(yourdatenumvector, 'ConvertFrom', 'datenum'); %convert to the more useful datetime
sum(hours(d(2:2:end) - d(1:2:end)))
  3 个评论
Guillaume
Guillaume 2018-6-18
In R2013a, it could possibly be calculated with:
sum(yourdatenumvector(2:2:end) - yourdatenumvector(1:2:end)) * 24
No guarantee that it works correctly. 2013a is ancient now.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Dates and Time 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by