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

    %% Create Table and Specify Variable Names  
% Create a table from arrays with different data types where each variable
% contains three rows.
T = table(categorical({'M';'F';'M'}),[45;32;34],...
    {'NY';'CA';'MA'},logical([1;0;0]),...
    'VariableNames',{'Gender' 'Age' 'State' 'Vote'}) 

%%
% |Gender| is a categorical array, |Age| is a double-precision array, |State|
% is a cell array of character vectors, and |Vote| is a logical array. You can use
% the function |summary| to print the data type and other information about
% the variables in the table.