%% Specify Data Variables
% Read data from a spreadsheet into a table. Use the first column of the spreadsheet as the row names of the table. Display the first three rows.

T1 = readtable('patients.xls','ReadRowNames',true);
head(T1,3)

%
% Reorient specified variables from T1 and discard the rest. To specify data variables by name, use a cell array of character vectors.

T2 = rows2vars(T1,'DataVariables',{'Gender','Age','Height','Weight'});
T2(:,1:4)

%
% You also can specify data variables by position in the input table. To specify positions of variables, use a numeric array.

T3 = rows2vars(T1,'DataVariables',[1 2 6:9]);
T3(:,1:4)

% Copyright 2012 The MathWorks, Inc.