Open in MATLAB Online 就是对 index 的两种表示,一种是用向量化的 0,1 矩阵表示,一种是用线性数值 1,2,3表示。 运行一下下面的例子就明白了: 1. 线性数值表示 vec = [1 0 0 0; 0 0 1 0; 0 1 0 1] ind = vec2ind(vec) vec = ...
ind2vec则反过来理解即可,如一个索引适量A=[1 3 2 2 2 1 2 1],求ind2vec?从A可以看出A是1行8列的(如果实在不知道,就用size(A)查看),从A中元素最大值"3"可以看出,索引对应的向量是3行的,还不理解?那就用最基本的方法,因A中元素对应的是行号,设B=ind2vec(A),意味着B(1...
This MATLAB function takes a row vector of indices, ind, and returns a sparse matrix of vectors, vec, containing a 1 in the row of the index they represent, as indicated by ind.