merge timetables in matlab

To merge timetables in Matlab, you can use the "outerjoin" function from the table class. This function performs a join between two tables based on matching rows in one or more specified columns.

Assuming you have two timetables called "timetable1" and "timetable2" with overlapping times, you can merge them as follows:

main.m
mergedTimetable = outerjoin(timetable1, timetable2, 'Keys', 'Time', 'MergeKeys', true);
88 chars
2 lines

The 'Keys' parameter specifies the column used to match the two tables, which in this case is the 'Time' column.

The 'MergeKeys' parameter specifies that the matching rows should be merged, rather than just concatenating the two tables together.

After merging, the resulting timetable will have columns from both original timetables, with missing values (NaNs) for any non-matching rows.

Note that in order to use the "outerjoin" function with timetables, the tables package must be installed.

main.m
%Check if tables package is installed
license('test','statistics_toolbox')
75 chars
3 lines

If the output is 1, it means the package is installed. If not, you can install it using the following command:

main.m
%Install tables package
matlab.addons.install('tables')
56 chars
3 lines

gistlibby LogSnag