Problem with assigning subset of multidimensional array
조회 수: 1 (최근 30일)
이전 댓글 표시
If there is a multidimensional array, say A= rand(3,4,2,2), it is easy to assign, say, the first page with B = A(:,:,1,:), using the colon operator. My problems: (1.) I dont know beforehand the number of dimensions ndim(A) of A and (2.) also not the dimension, in which the assignment will be. So in another case it might be the first row of a 3D-array which has to be assigned A(1,:,:).
Facing the 2. problem, I would use 'permute' or 'shiftdim' to place the dimension, where the assignment should be, to, say, the first dimension. For the example above: A = rand(3,4,2,2); A = shiftdim(A,2); % formerly 3.Dim is now on 1.position
But the 1. problem of unknown number of dimensions stay unsolved. Is there anybody who has an idea? Every help is appreciated.
Alex
댓글 수: 0
답변 (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!