table2timetable with Time as double
20 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello,
I have the following table :
The data come from a CAN trace, hence the varialbe time step.
My final goal is to do some analysis on the data.
My understanding is that it would be easier with a timetable and a resampling.
But I fail to convert this to a timetable :
my_timetable=table2timetable(my_traces(4).ewellix_num_data.fbk.ID04);
Error using table2timetable (line 59)
Input table must contain datetime or duration vector for row times.
my_timetable=table2timetable(my_traces(4).ewellix_num_data.fbk.ID04,"RowTimes","Time");
Error using table2timetable (line 135)
Row times must be datetime or duration vector.
I have the feeling that the type of Time variable is not correct but I had no luck trying to convert it.
Thanks
0 Commenti
Risposte (2)
Stephen23
il 6 Mag 2024
Spostato: Steven Lord
il 6 Mag 2024
You need to convert the TIME column/variable to e.g. a DURATION object.
For example, if the time is given in seconds then you could use the SECONDS function:
For example, where T is your table:
T.Time = seconds(T.Time)
Star Strider
il 6 Mag 2024
The resample function works with timetable arrays. See Resample Nonuniformly Sampled Data in Timetable for an example.
Timesec = sort(rand(30,1));
Time = datetime([zeros(numel(Timesec),5) Timesec], 'Format','ss.SSSS');
Position = sin(2*pi*Timesec) + randn(size(Timesec))/10;
TTx = timetable(Time,Position)
TTy = resample(TTx)
figure
plot(TTx.Time, TTx.Position, 'o-', 'DisplayName','Original Data')
hold on
plot(TTy.Time, TTy.Position, 's-', 'DisplayName','Resampled Data')
hold off
grid
xlabel('Time')
ylabel('Position')
legend('Location','best')
.
0 Commenti
Vedere anche
Categorie
Scopri di più su Descriptive Statistics in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!