www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/VerticallyConcatenateTwoTablesExample.m

    %% Vertically Concatenate Two Tables  

%% 
% Create a table, |A|, with three rows and five variables. 
A = table([5;6;5],['M';'M';'M'],[45;41;40],[45;32;34],{'NY';'CA';'MA'},...
    'VariableNames',{'Age' 'Gender' 'Height' 'Weight' 'Birthplace'},...
    'RowNames',{'Thomas' 'Gordon' 'Percy'})  

%% 
% Create a table, |B|, with the same variables as |A| except for order. 
B = table(['F';'M';'F'],[6;6;5],{'AZ';'NH';'CO'},[31;42;33],[39;43;40],...
    'VariableNames',{'Gender' 'Age' 'Birthplace' 'Weight' 'Height'})  

%% 
% Vertically concatenate tables |A| and |B|. 
C = vertcat(A,B) 

%%
% The variables of |C| are in the same order as the variables of |A| and
% default row names are used for the rows from |B|.