The ind2sub command determines the equivalentsubscript values corresponding to a single index into an array.
ind2sub 将数组中的索引转换成矩阵中的坐标。
[I,J] = ind2sub(siz,IND) 返回矩阵I(行下标),J (列下标)。siz是一个向量,siz(1)表示行数,siz(2)表示列数。IND 是索引。
>> a=[1 2 4;5 8 7;9 0 4];
>> ind=[2 5 7];
>> [i,j]=ind2sub(size(a),ind)
i =
2 2 1
j =
1 2 3