MATLAB: How to find the successive difference between timestamps in hours

datetime

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.

Best Answer

d = datetime(yourdatenumvector, 'ConvertFrom', 'datenum'); %convert to the more useful datetime
sum(hours(d(2:2:end) - d(1:2:end)))