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

    %% Number of Variables in Table  

%% 
% Create a table, |T|. 
LastName = {'Smith';'Johnson';'Williams';'Jones';'Brown'};
Age = [38;43;38;40;49];
Height = [71;69;64;67;64];
Weight = [176;163;131;133;119];
BloodPressure = [124 93; 109 77; 125 83; 117 75; 122 80];

T = table(Age,Height,Weight,BloodPressure,'RowNames',LastName)  

%% 
% Find the number of variables in table |T|. 
W = width(T) 

%%
% |T| contains |4| variables; |width| does not count the row names. 

%%
% The variable |BloodPressure| counts as one variable even though it contains
% two columns.