MATLAB: How to export ‘retime’ columns to xlsx

timetable2tablewritetimetable

I need a code that can take daily level measurements and automatically generate an output of monthly averages and counts. I have tried this already. But the specific problems are as follows:
(1) 'writetimetable' seems to be a valid function but my MATLAB gives an error of 'undefined function or variable writetimetable'. (2) So I thought I would try timetable2table first but I am getting the 'time column' wrong in that. It says I have unequal number of rows. I don't know how to join a datetime column with retime columns generated in MATLAB.
I have attached the test sheet I am working with.
And the code (as far as it works) is pasted below.
T = readtable('filename.xlsx');
T.date = datetime(T.date, 'Format','dd/MM/yyyy');
TT = table2timetable(T);
Tmean = retime(TT,'monthly','mean')
Tcount = retime(TT,'monthly','count')

Best Answer

writetimetable was introduced in R2019a. You might be using an older release of MATLAB.
Try this
T = readtable('monthly_average_test.xlsx');
T.date = datetime(T.date, 'Format','dd/MM/yyyy');
TT = table2timetable(T);
Tmean = retime(TT,'monthly','mean');
TmeanTable = timetable2table(Tmean, 'ConvertRowTimes', true);
writetable(TmeanTable, 'Tmean.xlsx');