Create a block diagonal, Toeplitz and triangular matrix given by n,B,C,A

4 vues (au cours des 30 derniers jours)
Rafael Nicolaou
Rafael Nicolaou le 28 Nov 2021
Commenté : Rena Berman le 13 Déc 2021
Hello everyone,
Im trying to create an mn x mn matrix using m x m matrices. For example:
A = [1 2; 3 4]
B=[9 10; 11 12]
C = [ 5 6; 7 8]
n = 3
Should give me this answer: Attached image.
  4 commentaires
Rafael Nicolaou
Rafael Nicolaou le 1 Déc 2021
Im sorry i restored the question..
Thanks my fault.
Rena Berman
Rena Berman le 13 Déc 2021
(Answers Dev) Restored edit

Connectez-vous pour commenter.

Réponses (1)

John D'Errico
John D'Errico le 28 Nov 2021
Modifié(e) : John D'Errico le 28 Nov 2021
The simplest answer is to use my blktridiag utility from the file exchange.
full(blktridiag(A,C,B,3))
ans =
1 2 9 10 0 0
3 4 11 12 0 0
5 6 1 2 9 10
7 8 3 4 11 12
0 0 5 6 1 2
0 0 7 8 3 4
By default, it produces a sparse matrix. Since you did not ask for that, I put a call to full around it.
Of course, if this is homework, then my answer is useless. If it is not, then my answer is the perfect solution. Find blktridiag on the File Exchange at this link:
Could you solve it using blkdiag? Well, yes, if this is your homework, with some effort. In that case, you you create the main diagonal of matrices from A? How might you do that? Perhaps that is a sufficient hint to get you started, IF this is your homework. Better is to just use code designed to solve your problem, efficient, already written and debugged.

Catégories

En savoir plus sur Sparse Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by