Apply blockdiag function over an array of matrices

I have an array of sparse matrices that I’d like to put into block-diagonal form. The syntax for the “blockdiag” function is like: blockdiag(A,B,C) where A, B and C are sparse matrices.
My array is quite large so I can’t do it element-wise. How can I pass all the elements of the array as an argument to blockdiag?

1 Like

So I’ve found the solution in case someone else is also confused with the same problem. The way to do it is to make use of the splat operator “…” so if the array of matrices is arr, then to take all the elements inside the array as an argument to blockdiag, one would write:
blockdiag(arr…)

1 Like