retime function not working

6 views (last 30 days)
Lara Zlateva
Lara Zlateva on 30 Nov 2019
Commented: Lara Zlateva on 1 Dec 2019
Hi,
I have a large timetable with information on daily temperatures in a town from 1977 to 2016. I am trying to get the mean, max and min temperatures of each month.However, when I try to use the retime function, I get the error message "Undefined function 'retime' for input arguments of type 'double'."
Here is my code up until now:
t=readtable('scottdata.xlsx', 'readvariablenames', true);
dt = datetime(Year, Month, Day);
tt = table2timetable(t(2:14611, :), 'rowtimes', dt);
monthly_mean = retime(MeanTempC, 'monthly', 'mean');
And here is an extract from the timetable (it also includes NaN values which show up as empty vectors, maybe this is where the problem sems from?) . The fourth column is MeanTempC :
01-Jan-1977 {'1977'} {'1'} {'1'} {'-2.8'} {0×0 char} {'-20.6'} {0×0 char} {'-11.7'}
02-Jan-1977 {'1977'} {'1'} {'2'} {'-5' } {0×0 char} {'-10' } {0×0 char} {'-7.5' }
Thank you for your help

Accepted Answer

Steven Lord
Steven Lord on 30 Nov 2019
The variable tt is a timetable, but is MeanTempC? Nowhere in your code do you define it, but from the error I would guess it is a double array, not a timetable. retime is only defined for timetable first inputs.
  1 Comment
Lara Zlateva
Lara Zlateva on 1 Dec 2019
You're right! I guess I should create a seperate timetable for each column I want to use. Thank you!

Sign in to comment.

More Answers (0)

Categories

Find more on Timetables 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!