A(I)
is an array formed from the elements of A
specified by the subscript vector I
. The resulting array is the same size as I
except for the special case where A
and I
are both vectors. In this case, A(I)
has the same number of elements as I
but has the orientation of A
.
A(I,J)
is an array formed from the elements of the rectangular submatrix of A
, specified by the subscript vectors I
and J
. The resulting array has length(I)
rows and length(J)
columns. A colon used as a subscript indicates all elements in that dimension. For example, A(I,:)
means all columns of those rows specified by vector I
. Similarly, A(:,J)
means all rows of columns specified by J
.
A(I,J,K,...)
is the array specified by the subscripts. The result is length(I)
-by-length(J)
-by-length(K)...
.
A{I}
where A
is a cell array and I
is a scalar forms a copy of the array in the specified cell of A
. If I
has more than one element, this expression is a comma-separated list. You can also use multiple subscripts that specify a scalar element, as in A{3,4}
.
A(I).field
when A
is a structure array and I
is a scalar forms a copy of the array in the field with the name field
. If I
has more than one element, this expression is a comma-separated list. If A
is a 1-by-1 structure array, then the subscript can be dropped. In this case, A.field
is the same as A(1).field
.