Use NxD array of indices to reference a D dimension array in matlab
조회 수: 2 (최근 30일)
이전 댓글 표시
I have a matlab matrix full of indices (indx) which can be N rows and D columns (and varies from execution to execution). I also have an output array of D dimensions, output(D1,D2,..,D_D). For a given indx, for example if D=3, a row of indx might equal (1, 2, 3), and I'd like to index output(1,2,3)=k.
However, I am not sure of two things.
1. I don't know D beforehand, how can I access a D length set of indices in output?
2. If so, is there any way accessing all ordered n-tuples in indx for each of their associated entry in output?
For 1, a remark here seems relevant: mathworks tip, specifically the part about "Indexing into an N-D array with N subscripts without knowing N ahead of time (see fftshift for an example)", except a) I'm indexing into an ND array without knowing D, and b) looking at fftshift did not help.
To be completely clear, here's some code illustrating the problem
qq(:,:,1)=[1 2; 3 4];
qq(:,:,2)=[5 6; 7 8];
indx=[1 1 1; 2 2 2] %to reference the coordinates (1,1,1)=1, and (2,2,2)=8
Thanks for looking at my question.
Edit* Sorry about qq missing the '8'.
댓글 수: 1
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!