How can i sum a time array

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

回答(1 个)

Walter Roberson
Walter Roberson 2018-6-20

0 个投票

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.

类别

帮助中心File Exchange 中查找有关 Numeric Types 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by