creating multidiagonal matrix from a basic square matrix

7 Ansichten (letzte 30 Tage)
Saeid
Saeid am 8 Okt. 2017
Kommentiert: Saeid am 8 Okt. 2017
For a finite difference code I need to create a multidiagonal matrix from a basic square matrix A:
How can I do this without using a for loop?

Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 8 Okt. 2017
Bearbeitet: Andrei Bobrov am 8 Okt. 2017
A = magic(3);
n = 8;
B = repmat({A},1,n);
out = blkdiag(B{:});

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by