How can I diagonalize a matrix which consists of matrix?

3 visualizaciones (últimos 30 días)
HYDYN
HYDYN el 20 de Sept. de 2018
Comentada: Steven Lord el 20 de Sept. de 2018
I have a matrix like this.
[[A]; [B]; [C]],
where, [A], [B], [C] are matrix having arbitral size. Actually, the real matrix I'm handling has much bigger size ([A], [B], [C], [D], [E], ... more than 100)
What I want to get is [[A] [0] [0]; [0] [B] [0]; [0] [0] [C]].
here, each [0] has proper matrix size.
I can do this using for-loop but I'd like to find a simpler and faster way.
Could you guys help me please?

Respuestas (1)

Steven Lord
Steven Lord el 20 de Sept. de 2018
Use blkdiag.
  2 comentarios
Sinwoo Jeong
Sinwoo Jeong el 20 de Sept. de 2018
Thank you for your comment. But that function makes me to type blkdiag(A, B, C, D, E, ...). In my case, I have more than 100 matrices. Could you please tell me how I can avoid typing every single matrix name?
Steven Lord
Steven Lord el 20 de Sept. de 2018
Store your matrices in a cell array instead of in individual variables.
C = {magic(5), ones(4), full(gallery('tridiag', 7))}
D = blkdiag(C{:})

Iniciar sesión para comentar.

Categorías

Más información sobre Operating on Diagonal Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by