How do I add data from one table to another?
显示 更早的评论
I have two tables of different sizes.
Table 1 is of size 1x28
Table 2 is of size 6x28
First table consists of the varibale names and the second table consists of the values of those variables. How do I copy the values from the second table and paste them below the variable names in the first table?
Final table size should be 7x28
Thanks in advance for your support
回答(1 个)
Hello, you can simply append the tables, see below for an example
Var1 = ["A";"B";"C";"D";"E"];
Var2 = [1;2;3;4;5];
Var3 = logical([1;0;1;0;1]);
Var4 = [10;20;30;40;50];
Var5 = rand(5,1);
T1 = table(Var1,Var2,Var3,Var4,Var5)
Var1 = ["F";"G";"H"];
Var2 = [6;7;8];
Var3 = logical([0;1;0]);
Var4 = [60;70;80];
Var5 = rand(3,1);
T2 = table(Var1,Var2,Var3,Var4,Var5)
% merge the tables
T = [T1;T2]
类别
在 帮助中心 和 File Exchange 中查找有关 Tables 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!