How can i sum a time array
Show older comments
I want to sum a time array which in seconds like 600 sec but i want to make it in minutes. on the other hand i have another array time difference that have 178 components. I want to make those time difference in minutes. So, I want to convert those time differences array in per minutes. So, I need 10 points or components for 600 SECONDS . here is the code that i have tried but can not work, tdif is the time difference array.
t=0;
i=1;
A=0;
for j=60:60:600;
A=i+A;
for i=i:1:length(tdif);
t = t + tdif(1,i);
if t>=j;
break
end
end
Answers (1)
Walter Roberson
on 20 Jun 2018
0 votes
The easiest way is to convert to timetable() objects and use retime()
If your times are at regular intervals, then you could reshape() or buffer() to get them into groups that you could then sum() or mean() as needed.
Categories
Find more on Numeric Types 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!