Okay, suppose I have a 3D matrix A and another 3D matrix Inds. What I would like to do is, for each stack A(i,j,:), permute that stack according to the indices given in Inds(i,j,:). Thus, if A(i,j,:) is [1.5 2.5 3.5] and Inds(i,j,:) is [3 2 1] then A(i,j,:) becomes [3.5 2.5 1.5].
Yes, I know A(i,j,:) is not a vector in Octave. Consider it shorthand for permute(A, [1 3 2])(i,:,j).
This should be simple, but for whatever reason I can’t seem to find the function to do it.
It matlab its quite simple:
In Matlab you can rearrange any vector using a vector of indices:
Ais now[60 50 40 10 20 30]If
AisMxNxP, when you useA(i,j,:)notation you are essentially dealing with aPx1vector that you can manipulate at will.