To combine two different tables with different lengths and widths into one, you can use MATLAB's table
function along with concatenate
or horzcat
function.
Here is a sample code to concatenate two tables Table1
and Table2
:
main.m261 chars7 lines
In this example, we have concatenated the two tables vertically, by stacking the rows of Table2 below rows of Table1. The resulting table CombinedTable
will have columns of both tables with NaN
values in cells where data is not available.
Alternatively, you can use join
function to merge two tables if they have one or more common columns.
main.m79 chars3 lines
In this example, we have merged two tables based on matching ID and Name columns. The resulting table MergedTable
will have columns of both tables with corresponding values merged together.
Hope this helps!
gistlibby LogSnag