table2timetable with Time as double
21 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I have the following table :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1687246/image.png)
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 Kommentare
Antworten (2)
Stephen23
am 6 Mai 2024
Verschoben: Steven Lord
am 6 Mai 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)
1 Kommentar
Star Strider
am 6 Mai 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 Kommentare
Siehe auch
Kategorien
Mehr zu Timetables 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!