Why doesn't Timetable command accept my time,data input?

2 visualizzazioni (ultimi 30 giorni)
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 ?

Risposta accettata

Adam Danz
Adam Danz il 23 Dic 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 Commenti
farzad
farzad il 25 Dic 2019
Modificato: farzad il 25 Dic 2019
dear Adam
What I desire to do , is to use this time vector or whatever format, in the rainflow 3d plot , as you see bellow, the top time history plot, you have Amplitude vs Time, while if I use
rainflow(X,'est') , I will only have Amplitue vs Samples.
to be able to have the time, I need to format the time double variable into the date and time, but the thing is : why should I ? maybe I receive a data acquisition results that the date - time is not mentioned in it. should I insert something arbitrary ?
the code :
fs = 100;
t = seconds(0:1/fs:100-1/fs)';
x = randn(size(t));
TT = timetable(t,x);
Display the reversals and the rainflow matrix of the signal.
rainflow(TT)
and link to the code : in the middle of the page : Cycle counting for timetable:
Adam Danz
Adam Danz il 26 Dic 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?

Accedi per commentare.

Più risposte (0)

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by