MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
Type of
Indexing

Result Syntax Rows Variables

Dot Indexing extracte
d data

T.var

T.
(varindex)

All rows One variable, specified
by var (a name) or by
varindex (a number)

Dot Indexing extracte
d data

T.var(rows
)

One or more rows,
specified by rows

One variable, specified
by var (a name)
Variables
Property

extracte
d data

T.Variable
s

All rows All variables when they
can be horizontally
concatenated into an
array
Subscripting
by Variable
Type

table S =
vartype(ty
pe);

T(rows,S)

One or more rows,
specified by rows

One or more variables
of the specified type
(for example,
'numeric')

Subscripting
by Variable
Type

extracte
d data

S =


vartype(ty
pe);

T{rows,S}

One or more rows,
specified by rows

One or more variables
of the specified type
(for example,
'numeric')

How to Specify Rows to Access


When indexing into a table with parentheses, curly braces, or dot indexing, you can
specify rows as a colon, numeric indices, or logical expressions. Furthermore, you can
index by name using a single row name or a cell array of row names.


A logical expression can contain curly braces or dot indexing to extract data from which
you can define the subset of rows. For example, rows = T.Var2>0 returns a logical
array with logical true ( 1 ) for rows where the value in the variable Var2 is greater than
zero.


How to Specify Variables to Access


When indexing into a table with parentheses or curly braces, you can specify vars as a
colon, numeric indices, logical expressions, a single variable name, a cell array of variable
names, or as the output of the vartype function..


Access Data in a Table
Free download pdf