How can I retime my timetable with a 10days timestep?

Hi guys,
I need to retime my hourly timetable to an average 10days time step. Then apply an index to them.
I know that predefine timesteps like hourly or monthly exist in m,atlab but 10day time interval??
Thanks in advance

 Accepted Answer

Read the documentation...
TT2 = retime(TT1,'regular',method,'TimeStep',dt) calculates regularly spaced row times using the time step dt. The dt input argument is a scalar duration or calendar duration, specifying a time step of any size. The row times of TT2 span the range of row times of TT1.
Use this syntax when the time step is not one of the predefined time steps you can specify as a character vector or string.

5 Comments

I read it but i could not find out how can i put 10days in the code and define mean.
Ewww....by bad. I misinterpreted the doc myself. I didn't realize retime doesn't allow an aggregation method with a dt specification instead of a full new time vector first.
See Steven's answer instead.
The former seems a shortcoming in implementation altho not a bug since does not promis that can...
It does, actually, unless I'm misunderstanding:
>> tt = timetable(rand(25,1),'RowTimes',datetime(2020,5,5,12:36,0,0));
>> head(tt)
ans =
8×1 timetable
Time Var1
____________________ _______
05-May-2020 12:00:00 0.63274
05-May-2020 13:00:00 0.43933
05-May-2020 14:00:00 0.8247
05-May-2020 15:00:00 0.68898
05-May-2020 16:00:00 0.70221
05-May-2020 17:00:00 0.98715
05-May-2020 18:00:00 0.95441
05-May-2020 19:00:00 0.85127
>> retime(tt,'regular','mean','TimeStep',caldays(1))
ans =
2×1 timetable
Time Var1
___________ _______
05-May-2020 0.62712
06-May-2020 0.63855
Hmmmm, Peter. I can't find what I had tried in command history now to see what I did wrong to draw the conclusion couldn't get there from here...somehow I had convinced myself something wasn't right but can't reproduce what that was at the moment.
Thanks for straightening out...

Sign in to comment.

More Answers (1)

Pass a datetime vector as the newTimes input to retime as shown in the Interpolate Timetable Data to Time Vector example on the documentation page.

Categories

Products

Release

R2018b

Tags

Community Treasure Hunt

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

Start Hunting!