• The dot indexing subscript is valid.
MATLAB always attempts to apply the dot indexing operation to the temporary variable, even if the
function returns a variable for which dot indexing is not defined. For example, if you try to index into
the matrix created by magic(3), then you get an error.
magic(3).field
Dot indexing is not supported for variables of this type.
You can add more indexing commands onto the end of an expression as long as the temporary
variables can continue to be indexed. For example, consider the expression:
table(rand(10,2)).Var1(3,:)
In this expression, you index into a table to get the matrix it contains, and then index into the matrix
to get the third row:
• table(rand(10,2)) creates a table with one variable named Var1. The variable contains a 10by-2 matrix.
• table(rand(10,2)).Var1 returns the 10-by-2 matrix contained in Var1.
• table(rand(10,2)).Var1(3,:) returns the third row in the matrix contained in Var1.
See Also
function | subsref
More About
•
“Types of Functions” on page 20-17
•
“Array Indexing”
•
“Access Data in Tables” on page 9-32
Indexing into Function Call Results
20-47
Précédent

- 755/1450

Suivant