%% Insert Variables at Specified Locations
% Create a table. Then insert variables before and after specified locations in the table.
% Load arrays from the patients.mat file. Create a table that contains the names and genders of patients. Then display the first three rows.

load patients
T1 = table(LastName,Gender);
head(T1,3)

%
% Insert the workspace variable, Age, before the table variable, Gender. To refer to a table variable by name, specify its name as a character vector.

T2 = addvars(T1,Age,'Before','Gender');
head(T2,3)

%
% Insert more variables after Age. Since Age is a table variable in T2, specify its name as a character vector.

T3 = addvars(T2,Height,Weight,'After','Age');
head(T3,3)

%
% Insert Smoker after the first table variable. You can specify variables by position in the table instead of by name.

T4 = addvars(T3,Smoker,'After',1);
head(T4,3)

% Copyright 2012 The MathWorks, Inc.