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!