MATLAB: Interpolate time series data for the same time period on each day

interpolationtime series

Hi,
I'm new to Matlab, so please forgive me if I'm asking an easy question.
I have created a timetable TT1 for minutely interpolation,
TT1 = timetable(DateTime,Close);
for example:
'02-Jan-1990 09:31:00' 353.40
'02-Jan-1990 09:32:00' 353.25
'02-Jan-1990 10:33:00' 353.02
'02-Jan-1990 12:34:00' 352.97
'02-Jan-1990 15:59:00' 352.81
Then I used retime to interpolate data for the first period
DateTime1=[datetime('02-Jan-1990 09:31:00'):minutes(1):datetime('02-Jan-1990 15:59:00')];
TT2 = retime(TT1,DateTime1,'linear');
However, I got more than 6000 trading days to do this 'minutely' interpolation.
The results should be a timetable with a column 'Close' for 6000 days (which is not linear) from 09:31 to 15:59
Is there any better ways than repeatedly typing in the same codes with 6000 different Dates?
Thanks for your help!

Best Answer

Here's one way to do it.
%%Original timetable, 5 minute intervals
t=[datetime('1990-1-1 00:00'):minutes(5):datetime('1990-1-8 00:00')]';
t(day(t)==3)=[];
t(day(t)==6)=[];
TT=timetable(t,[1:length(t)]');
%%List of unique days
uDays=unique(datetime(year(t),month(t),day(t)));
%%New time-series 1 min interval over 2 days
t_new=[datetime('1990-1-1 00:00'):minutes(1):datetime('1990-1-8 00:00')]';
Days=datetime(year(t_new),month(t_new),day(t_new));
%%Remove irrelevant times
t_new(~ismember(Days,uDays))=[];
t_new(hour(t_new)<9)=[];
t_new(hour(t_new)>16)=[];
t_new(hour(t_new)==9 & minute(t_new)<30)=[];
%%Interp
retime(TT,t_new,'linear')
I think this should give you what you want. Only problem is you need to store a datetime-array with 8 million rows temporarily (~ 60 MB)