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

    %% Horizontally Concatenate Two Tables  

%% 
% Create a table, |A|, with three rows and two variables. 
A = table([5;6;5],['M';'M';'M'],...
    'VariableNames',{'Age' 'Gender'},...
    'RowNames',{'Thomas' 'Gordon' 'Percy'})  

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

%% 
% Horizontally concatenate |A| and |B|. 
C = horzcat(A,B) 

%%
% The order of rows in |C| matches the order in |A|.