ind2sub函数可以用来把矩阵元素的index转换成对应的下标(determines the equivalent subscript values corresponding to a single index into an array)
例如: 一个4*5的矩阵A,第2行第2个元素的index的6(matlab中matrix是按列顺序排列),可以用ind2sub函数来计算这个元素的下标 [I,J] = ind2sub(size(A),6)
[I,J] = ind2sub(siz,IND) returns the matrices I and J containing the equivalent row and column subscripts corresponding to each linear index in the matrixIND for a matrix of size siz. siz is a vector with ndim(A) elements (in this case, 2), where siz(1) is the number of rows andsiz(2) is the number of columns.
例子:For matrices, [I,J] = ind2sub(size(A),find(A>5)) returns the same values as[I,J] = find(A>5).
最后
以上就是纯真水壶最近收集整理的关于ind2sub函数使用方法的全部内容,更多相关ind2sub函数使用方法内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复