table2timetable with Time as double
20 views (last 30 days)
Show older comments
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 Comments
Answers (2)
Stephen23
on 6 May 2024
Moved: Steven Lord
on 6 May 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
on 6 May 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 Comments
See Also
Categories
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!