Reputation: 1637
How do I merge two tables together?
Table 1:
LastName Age Weight Smoker
__________ ___ ______ ______
'Smith' 38 176 true
'Johnson' 43 163 false
'Williams' 38 131 false
Table 2:
LastName Age Weight Smoker
__________ ___ ______ ______
'Jones' 40 133 false
'Brown' 49 119 false
into:
LastName Age Weight Smoker
__________ ___ ______ ______
'Smith' 38 176 true
'Johnson' 43 163 false
'Williams' 38 131 false
'Jones' 40 133 false
'Brown' 49 119 false
Upvotes: 2
Views: 779
Reputation: 19689
You can simply do this using:
Complete_Table=[Table1;
Table2]
Complete Code:-
LastName = {'Smith';'Johnson';'Williams'};
Age = [38;43;38];
Weight = [176;163;131];
Smoker=logical([1;0;0]);
Table1 = table(LastName,Age,Weight,Smoker)
%Overwriting
LastName = {'Jones';'Brown'};
Age = [40;49];
Weight = [133;119];
Smoker=logical([0;0]);
Table2 = table(LastName,Age,Weight,Smoker)
Complete_Table=[Table1;
Table2]
Output:-
Table1 =
LastName Age Weight Smoker
__________ ___ ______ ______
'Smith' 38 176 true
'Johnson' 43 163 false
'Williams' 38 131 false
Table2 =
LastName Age Weight Smoker
________ ___ ______ ______
'Jones' 40 133 false
'Brown' 49 119 false
Complete_Table =
LastName Age Weight Smoker
__________ ___ ______ ______
'Smith' 38 176 true
'Johnson' 43 163 false
'Williams' 38 131 false
'Jones' 40 133 false
'Brown' 49 119 false
Upvotes: 2