They want this:
clear clc M(:,:,1) = [1,2;3,4]; M(:,:,2) = [21,22;23,24]; J = [1,2; 2,1];
They tried this:
ans = [1 22 23 4]
This video discusses this solution:
D = M(:,:,J) % This doesn't work,
[nR, nC] = size(J); D = zeros(nR,nC); for r = 1:nR for c = 1:nC D(r,c) = M(r,c,J(r,c)); end end
To leave a comment, please click here to sign in to your MathWorks Account or create a new one.