2017-06-13 57 views
0

假设我有一个位置的矢量= [3; 4; 10]。我想将矢量转换为20行的逻辑形式,其中3,4和10行等于1,其余为零。将未知的向量位置转换为N的逻辑形式

我把这样的

N=20; 
LOC=[3;4;10]; %location of the original point 
LOGIC= % 20 logical rows where only row 3,4 and 10 equal to 1 

会有什么逻辑函数的参数?

回答

0
iwant = zeros(20,1) ; 
loc = [3 4 10] ; 
iwant(loc) = 1 ; 
iwant = logical(iwant) ; 
+0

Thanx Siva为您提供帮助 – Acobot