필터 지우기
필터 지우기

How to find the successive difference between timestamps in hours?

조회 수: 1 (최근 30일)
Devansh Patel
Devansh Patel 2018년 6월 18일
댓글: Devansh Patel 2018년 6월 19일
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.
Devansh Patel
Devansh Patel 2018년 6월 19일
It works! Thankyou so much!

댓글을 달려면 로그인하십시오.

추가 답변 (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