Why doesn't Timetable command accept my time,data input?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
farzad
am 23 Dez. 2019
Kommentiert: Adam Danz
am 26 Dez. 2019
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 ?
0 Kommentare
Akzeptierte Antwort
Adam Danz
am 23 Dez. 2019
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.
7 Kommentare
Adam Danz
am 26 Dez. 2019
If the x axis should represent time, the use of datetime values would be ideal. If the x axis should represent durations, it would be easy to convert the datetime values to duration. Either way the datetime values are more useful than other date/time formats.
" I need to format the time double variable into the date and time, but the thing is : why should I ?"
Here's an example why datetime values are the appropriate representation of time variables.
Suppose I have a vector of timestamps in the format yyyyMMddhhmmss. The two values below show Feb 1 2020 to March 1 2020. How many days are between those two days? How many hours? That can't be calculated from these values without an extensive amount of work. The numbers don't actually represent date and time - they are merely a code that you defined by the format above.
t = [20200201000000, 20200301000000]
If those values were converted to datetime values, the numbers become meaningful and interpretable. You can easily compute days, hours, months, etc and the spacing of the datetime ticks along the x-axis will be meaningful.
" maybe I receive a data acquisition results that the date - time is not mentioned in it. should I insert something arbitrary ?"
Missing data is a problem no matter what format the time variables are in. Sometimes the context of the data will help to decide how to fill those values. For example, are the data acquired at a fixed rate? Can the surrounding known times be used to fill in the missing times? Can the missing values be estimated using linear interpolation?
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Design Condition Indicators Interactively finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!