%% Names of Output Table Variables
% Read data from a spreadsheet into a table. Display the first three rows.

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

%
% Reorient the rows of T1 to be variables of a new table, T2. Specify that the LastName variable from T1 is the source of the names of the variables of T2.

T2 = rows2vars(T1,'VariableNamesSource','LastName');

%
% Display the first four variables of T2. The first variable of T2 contains the names of the variables of T1. The remaining variables of T2 correspond to rows of T1.

T2(:,1:4)

%
% Display the data in T2.Smith. In this example, every variable of T2 is a 9-by-1 cell array, because the values in the rows of T1 cannot be concatenated into arrays.

T2.Smith

% Copyright 2012 The MathWorks, Inc.