append rows of a table

96 ビュー (過去 30 日間)
Robert 2021 年 7 月 27 日
コメント済み: Peter Perkins 2021 年 7 月 28 日
So i would like to take two tables lets say T1 and T2
I want to take a single line if T2 and append it to the end of T1.
I found this could as an example. It works just fine except it appends the enitre table. I want to just append a single row from T2 and tack it on to the end of T1.
Anyone have any ideas?
T2 = readtable('morePatients.csv');
Tnew = [T;T2];
  5 件のコメント
Peter Perkins
Peter Perkins 2021 年 7 月 28 日
Correct. If the two sets of var names differ only by permutation, vertcat matches them up. If the two sets are more different than that, that's a whole 'nuther question.


回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 7 月 27 日
The general solution is to vertcat or [;] a cell array that has the same number of columns that as the table has variables. This will work even if the table contains multiple data types. Values being appended will have their type converted if necessary.
You might need to use table2cell if your table has multiple data types.
Or if the variable names match you can just vertcat T2(1,:)


Find more on Tables 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!

Translated by