I know that to generate a block-diagonal matrix in Matlab the command blkdiag
generates such a matrix:
Now I am faced with generating the same block-diagonal matrix, but with also matrix elements B_1
, B_2
,..., B_{n-1}
on the upper diagonal, zeros elsewhere:
- I guess this can be hardcoded with loops, but I would like to find a more elegant solution. Any ideas on how to implement such a thing?
P.S. I diag
command, that using diag(A,k)
returns the k
th diagonal. I need something for writing in the matrix, for k
>0, and for block matrices, not only elements.