How can I diagonalize a matrix which consists of matrix?
3 views (last 30 days)
Show older comments
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?
0 Comments
Answers (1)
Steven Lord
on 20 Sep 2018
2 Comments
Sinwoo Jeong
on 20 Sep 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
on 20 Sep 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{:})
See Also
Categories
Find more on Operating on Diagonal Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!