MATLAB: Doesn’t Timetable command accept the time,data input

matrix

Hi All
I use the command
TT = timetable(t,X);
but I get the following error, despite having defined t as a nx1 matrix and X the same
Error using timetable (line 291)
Provide datetime or duration vector for row times to create timetable.
How should I debug it ?

Best Answer

The error message tells you what's wrong.
"Provide datetime or duration vector for row times to create timetable."
Apparently t is not a datetime or duration or perhaps it's not a vector. To determine which is the problem you could just look at the content of the variable. You could also run these two diagnostic lines.
class(t)
size(t)
If you've got a datetime or duration variable that is not a vector, you could convert it to a vector using
t(:)
If t is not a datetime or duration, you'll need to convert it to one of those classes. I'd be glad to help out if you get stuck.