请教下vec2ind 和ind2vec函数的作用,最好举例说明下

 Accepted Answer

就是对 index 的两种表示,一种是用向量化的 0,1 矩阵表示,一种是用线性数值 1,2,3表示。
运行一下下面的例子就明白了:
1. 线性数值表示
vec = [1 0 0 0; 0 0 1 0; 0 1 0 1]   
ind = vec2ind(vec)  
vec =
1 0 0 0
0 0 1 0
0 1 0 1
ind =
1 3 2 3
2. 向量化 0,1 表示
ind = [1 3 2 3]
vec = full(ind2vec(ind))
ind =
1 3 2 3
vec =
1 0 0 0
0 0 1 0
0 1 0 1

More Answers (0)

Categories

Find more on 矩阵和数组 in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!