MATLAB: Rearranging of matrix in order to avoid loop

avoid looprearrange matrix

In the following code, my goal is to avoid the for-loop (i=1:m). I have already tried several things, but all of them failed.
m = 3;
n = 10;
ii = [1:n;3:n+2;2:n+1]; % index vector with size (m,n)

jj = [3:n+2;2:n+1;1:n]; % index vector with size (m,n)
load E.mat %external file see attachment
res = zeros(n,n,m);
for i=1:m;
res(:,:,i) = E(ii(i,:),jj(i,:),1,1);
end
How can I avoid the loop? In the attachment you can find the reference output matrix res.mat which contains the matrix res generated by this code. A code without the loop should reproduce the result saved in res.mat.

Best Answer

>> II = repmat(permute(ii,[2,3,1]),1,10,1);
>> JJ = repmat(permute(jj,[3,2,1]),10,1,1);
>> rex = E(sub2ind(size(E),II,JJ));
>> isequal(rex,res)
ans = 1