I have a large sparse matrix that I'm working on, but for simplicity I have written it below as shown:
row = [1,3];
col = [1,3];
val = [22,33];
B = sparse(row,col,val,3,3)
22 0 0
0 0 0
0 0 33
This matrix is singular and does not have an inverse that I can use for a solution of:
[A]=[B][C]
=> [B]\[A] = [C]
.
To remedy this, all of the rows and columns containing only zero need to be removed. So, in the example above, I would remove row 2 and column 2 before I create the sparse matrix.
But if I try this, the index described by the row and col vectors (3,3) will point outside the matrix dimensions and give me an error. What is something I can do to solve this problem?