I have a set of timetables inside a cell TT, each of them with a resolution of 15 minutes, the timetables have different starts and ends, different sizes (missing data for each are different). What I want to do is set all these time tables to a common time vector, and then fill all the missing data with NaN. If I use retime (for one timetable) in this from:
TT1new = retime(TT{1},'regular','fillwithmissing','TimeStep',minutes(15));
it fills NaN but within the time range of TT1, and not of my time vector. So it seems to me that in order to use my time vector "retime" is of no use, instead I have done the following:
tini = datetime({'01-Apr-2016 00:00:00'});tfin = datetime({'01-Apr-2017 00:00:00'});timeVector = [tini:datenum([0,0,0,0,15,0]):tfin]';%I built a reference timetable full of NaN, (I have 3 variables in each timetable)
ttref = timetable(timeVector,NaN(length(timeVector),1),NaN(length(timeVector),1),NaN(length(timeVector),1));%Then I plan to fill the non-missing data in the reference timetable for each timetable, and capture the result in TTFit
num = length(TT);TTFit = cell(num,1);for i=1:num temp=ttref; range = timerange(max(tini,TT{i}.Time(1)),min(tfin,TT{i}.Time(end)),'closed'); temp(TT{i}(range,:).Time,:).Variables = TT{i}(range,:).Variables; TTFit{i}=temp;end
But it takes an eternity (more than 20 minutes so far and yet dont know if it works) to finish the run. Is there an easier and efficient way to do that? Any hints would be really apreciatted.
Best Answer