I would like to clarify if indexing is supported for multidimensional arrays.
For example, consider the code below.
According to the help page, the line B2 = A(I) a recover the sorted array.
However, from MATLAB Online R2020b the code snippet produces array full of ones as the result for B2.
A(:,:,1) = 1*ones(3);A(:,:,2) = 2*ones(3);A(:,:,3) = 3*ones(3);A(:,:,4) = 4*ones(3);[B,I] = sort(A,3,'descend');B2 = A(I);
Best Answer