I am trying to figure out if it is possible to access to multiple blocks of a diagonal block matrix, in MATLAB.
For example, let's say I have this (ideally sparse, but could be dense too) block matrix
|A A 0 0|
|A A 0 0|
M = |0 0 B B|
|0 0 B B|
I know that, for example, one can access to the first sublock as M(1:2,1:2)
, but I cannot find a way to access to non sequencial cells.
Is there a way to access with a single command to the submatrices A and B. Ultimately I am interested in updating a really large sparse block matrix very quick.
To clarify, in my case the block diagonals are always the same size. I know I can update them in two commands doing M(1:2,1:2) = 1
and M(3:4,3:4) = 2
, but can I do both in a single access? Also, I need to keep M
as a 2D matrix since is used afterwards in matrix multiplication operations.
M([1 3],[1 3])
? – Ander Biguri