How to convert decimal hour and calculate the average every 5 min?
Show older comments
Hello all! I'm a beginner at Matlab and I need to solve a problem. First, I need to convert the UT columm from decimal hour to hour:minute:seconds. Then, I need to calculate every 5 minutes on average the ROT collumn and show the reply in a new matrix (hour:min:sec,rot mean).
Example:

e.g. UT (5.404)=0.404*60=24.252; 0.252*60=15.12 ,then UT(5.404)=5:24:15 hours:min:sec
Thanks in advance
Marcelo
2 Comments
Doug Hull
on 15 Nov 2013
Why are you dropping the 0.004 in the first step?
>> [Y, M, D, H, MN, S] = datevec(5.404/24)
Y =
0
M =
0
D =
0
H =
5
MN =
24
S =
14.4000
Marcelo Duarte
on 16 Nov 2013
Accepted Answer
More Answers (1)
Andrei Bobrov
on 17 Nov 2013
k = rem(UT,1)*60;
tms = fix([UT,k]);
m = ceil(k/5)*5;
[~,b,ii] = unique(m);
out = [tms(b,:), accumarray(ii,ROT,[],@mean)];
1 Comment
Marcelo Duarte
on 18 Nov 2013
Categories
Find more on Time Series Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!