MatrixBerryCore
ind2submat.m
Go to the documentation of this file.
1 function indMat = ind2submat(sizeVec,indVec)
2 nout = length(sizeVec);
3 sizeVec = double(sizeVec);
4 sizeVec = [sizeVec ones(1,nout-length(sizeVec))];
5 %
6 n = length(sizeVec);
7 k = [1 cumprod(sizeVec(1:end-1))];
8 for i = n:-1:1
9  vi = rem(indVec-1, k(i)) + 1;
10  vj = (indVec - vi)/k(i) + 1;
11  indMat(:,i) = vj;
12  indVec = vi;
13 end
function ind2submat(in sizeVec, in indVec)
IND2SUBMAT works similarly to the built-in ind2sub function but returns all the indices in a single m...