matlab之sub2ind,函数

将下标转换为线性索引

语法

linearInd = sub2ind(matrixSize, rowSub, colSub)

说明

nCols] 形式指定矩阵中的行和列数。rowSubcolSub 输入是正整数标量或向量,指定矩阵的一个或多个行-列下标对组。

来源:https://ww2.mathworks.cn/help/matlab/ref/sub2ind.html?searchHighlight=sub2ind&s_tid=doc_srchtitle