how to make a timetable with one column in matlab

To create a timetable with one column in Matlab, you can use the timetable function along with the datetime function. Here's an example:

main.m
% Create a datetime column
time = datetime('now') + hours(1:5);

% Create a data column
data = [10 15 20 25 30]';

% Create the timetable
tt = timetable(time,data);

% Display the timetable
disp(tt)
199 chars
12 lines

This will create a timetable with a single column containing the data 10 15 20 25 30, and row times spaced one hour apart from datetime('now') to 5 hours into the future.

Output:

main.m
            data
            ____
Time                     
19-Oct-2021 19:58:51    10
19-Oct-2021 20:58:51    15
19-Oct-2021 21:58:51    20
19-Oct-2021 22:58:51    25
19-Oct-2021 23:58:51    30
195 chars
9 lines

You can add more columns by creating additional data vectors and passing them to the timetable function along with the time column.

gistlibby LogSnag