The reason this happens is because 'fillmissing' is not meant to be called on a table with multiple data types using this syntax. There are two data types in table 't' and 'fillmissing' is trying to replace all empty values with 0. Because 0 is not a valid datetime, the error is thrown. You can try one of the following:
1) If only the first column of the table is datetime data and the rest is numeric, run the command:
t(:,2) = fillmissing(t(:,2),'constant',0)
This function call will only work since the rest of the table is of the same datatype: numeric.
2) Specify which datatype needs to be replaced with the following command:
fillmissing(t,'constant',-1, 'DataVariables', @isnumeric);
In this case, all columns with numeric data will be affected by this command. If the datatimes needed to be replaced, the following command would work:
fillmissing(t,'constant',datetime('now'), 'DataVariables', @isdatetime);
For tables with multiple datatypes, one 'fillmissing' call must be made for every unique datatype in the table.
Best Answer