How to index a matrix properly?



I have a matrix:
A=false(6,6)
A =
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
I have three pairs of indexes I and J
I=[2 4 6];
J=[1 3 5];
I want the three elements A(2,1), A(4,3) and A(6,5) to be true
What should I do? If I use:
A(I,J)=true;
I receive:
A
A =
0 0 0 0 0 0
1 0 1 0 1 0
0 0 0 0 0 0
1 0 1 0 1 0
0 0 0 0 0 0
1 0 1 0 1 0
But I need only three indexes to be true, not all combinations. What should I do? Is another way how to index the matrix properly?
(I know,.. the solution..
for i=1:1:length(I);
A(I(i),J(i))=true;
end;
But..this solution is time consuming.. do you know something more elegant?
Any advice?
Miroslav Pavelka






.