→ celestialgod: 我猜 A(1:20, B(:))=1應該可以 05/10 00:53
謝謝建議,但try過了不行
>> A=zeros(2,3)
A =
0 0 0
0 0 0
>> A(:,[1 3])=1
A =
1 0 1
1 0 1
因為我是想要
1 0 0
0 0 1
推 sunev: sub2ind 05/10 01:25
※ 編輯: polymerase (73.171.14.119), 05/10/2015 12:23:33
A=zeros(2,3);
B=[1 3];
C=[1 2; B];
ind=sub2ind(size(A),C(1,:), C(2,:))
% ind = 1 6
A(ind)=1
A =
1 0 0
0 0 1
sunev你是我的matlab神
膜拜
※ 編輯: polymerase (73.171.14.119), 05/10/2015 12:31:36