%% Extract Data from Specified Rows and Variables
% Indexing with curly braces extracts data from a table and results in an array, not a subtable. But other than that difference, you can specify rows and variables using numbers, names, and data type subscripts, just as you can when you index using smooth parentheses. To extract values from a table, use curly braces. If you extract values from multiple table variables, then the variables must have data types that allow them to be concatenated together.
%
%% Specify Rows and Variables
% Create a table from numeric and logical arrays from the patients file.

load patients

T = table(Age,Height,Weight,Smoker,...
    'RowNames',LastName);

% Extract data from multiple variables in T. Unlike dot notation, indexing with curly braces can extract values from multiple table variables and concatenate them into one array.
% Extract the height and weight for the first five patients. Use numeric indices to select the first five rows, and variable names to select the variables Height and Weight.

A = T{1:5,{'Height','Weight'}}

% A is a 5-by-2 numeric array, not a table.
% If you specify one variable name, then curly brace indexing results in the same array you can get with dot notation. However, you must specify both rows and variables when you use curly brace indexing. For example, this syntaxes T.Height and T{:,'Height'} return the same array.
%
%% Extract Data from All Rows and Variables
% If all the table variables have data types that allow them to be concatenated together, then you can use the T.Variables syntax to put all the table data into an array. This syntax is equivalent to T{:,:} where the colons indicate all rows and all variables.

A2 = T.Variables

% Copyright 2015 The MathWorks, Inc.