How do I make a block diagonal matrix using blkdiag function for a N dimensions

6 次查看(过去 30 天)
I have a matrix A which can be converted using the
blkdiag(A,A);
for 2D and m
blkdiag(A,A,A);
for 3D but I want the user to input the dimension and based on that a block diagonal matrix has to be generated something like
blkdiag(A,A,A....An);
. I know we have to use loops but i cant wrap my head around the actual code, if anyone could help that'd be great !

采纳的回答

Andrei Bobrov
Andrei Bobrov 2019-8-4
C = repmat({A},n,1);
out = blkdiag(C{:});

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Operating on Diagonal Matrices 的更多信息

标签

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by