I have a sparse matrix in MATLAB which dimensions are: 8970240 x 8970240 = L x L. Let's call it M.
I have to assign to a lot of elements in the matrix the value of 1, for example, given the pair of index i and j: M(i, j) = 1.
I have indices where I want to perform the assignment stored in vectors, this is:
- One dimension vector
V1stores the row indices (i's). - One dimension vector
V2stores the column indices (j's).
Now, the issue is that the length of V1 (7004160) is different to the length of V2 (6389760). Which also returns a lot of nonzero elements in my sparse matrix, a total of 7004160 x 6389760 = 44754901401600 = A nonzero elements.
I have tried to construct M this way:
M = sparse(V1, V2, ones(A), L, L)
But it does not work...
Does anybody know how to get around it?
v1andv2cannot be different sizes! if they areiandj, what happens when you run out ofv2?M(v1(7004160) , ?????? ) =1- Ander BiguriM(1, 3) , M(1, 65) , M(5, 3), M(5, 65) , M(12, 3) and M(12, 65). I honestly do not know if there is any way to do that. - Smolpisparsedata type, will take more memory that if you were to fill it completely, as a sparse matrix needs to store 3 values for each non-zero, 2 indices and 1 value. - Ander Biguri