MATLAB: Write missing data as NaN

complete missing datanantimeserie

I have multiple rain time series with 15 minute interval, but with some missing datas, like this:
yyyy mm dd hh mm ss data
2000 01 30 11 00 00 3.00
2000 01 30 11 15 00 2.00
2000 01 30 11 45 00 0.00
2000 01 30 12 00 00 0.00
And I need to add the missing datas with NaN at data row, resulting this
yyyy mm dd hh mm ss data
2000 01 30 11 00 00 3.00
2000 01 30 11 15 00 2.00
2000 01 30 11 30 00 NaN
2000 01 30 11 45 00 0.00
2000 01 30 12 00 00 0.00
There's some way to do that in MatLab?
Tks

Best Answer

OK, without timetable and retime...
dt=(datetime(data(1,1:6)):minutes(15):datetime(data(end,1:6))).'; % build the full time vector
t=table(dt,nan(size(dt)),'VariableNames',{'Time','Rain'}); % empty table
ix=ismember(t.Time,datetime(data(:,1:6))); % data available locations
t.Rain(ix)=data(:,end) % and insert...
t =
5×2 table
Time Rain
____________________ ____
30-Jan-2000 11:00:00 3
30-Jan-2000 11:15:00 2
30-Jan-2000 11:30:00 NaN
30-Jan-2000 11:45:00 0
30-Jan-2000 12:00:00 0
>>