Hi all,
I have a sparse matrix:
a = sparse(9,9)
I also have two sets of information:
i =
7 8 9
j =
1 2 6
So, I want to take i as a row reference and j as a column reference and output it to the sparse matrix. So, if I do:
a(i,j) = -1
Output Window:
a =
(7,1) -1 (8,1) -1 (9,1) -1 (7,2) -1 (8,2) -1 (9,2) -1 (7,6) -1 (8,6) -1 (9,6) -1
When I only want:
a =
(7,1) -1 (8,2) -1 (9,6) -1
or, I only to output to a when position of i is equal to position of j. I have tried certain things with "for" and "if" loops but haven't been able to come up with the right answer.
Can anyone please help me with this, thank you in advance.
Best Answer