Mixing subscripts with linear indices
显示 更早的评论
Generally speaking, I have found that it has always been possible to mix subscript and linear array indexing, as long as the indexing syntax is in the form,
A(subscript_1,subscript_2,...,subscript_n, linear_index).
For example, given,
A = reshape((1:24)*3, [4, 3, 2]);
all of the following are valid ways of indexing the final element in A,
A(4,3,2)
A(4,6)
A(24)
However, I haven't been able to find documentation of this, except of course for the trivial case where n=0. Is it officially supported behavior?
1 个评论
Same example as above, with other cases
A = reshape((1:24)*3, [4, 3, 2])
The linear index can be a vector
A(:,[3 5])
Or a colon
A(2,:)
A(:,:)
Or even an array, which gets stretched into a vector index
A(:,[1:2;1:2])
I too can't find relevant documentation.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!