Block diagonal change the first and last blocks with some other matrices

1 visualizzazione (ultimi 30 giorni)
N=5;
C=sparse(zeros(N-1));
C([1 end])=C([1 end])+1;
B=speye(N-1);
B([1 end])=B([1 end])-1/2;
I have B and C matrices. I can form a blockdiagonal matrix such that C on the diagonal. As follows;
E0=speye(N);
E0=E0(1:end-1,1:end-1);
T2=kron(E0,C);
But I want to change the first and the last blocks with the matrix B.( In the first block and last block instead of C there should be B matrix.)
How can I do that? (N will be a variable so the size of the matrix will change according to the written N value.)

Risposte (1)

David Hill
David Hill il 16 Giu 2021
Why not use blkdiag() function?
T=blkdiag(B,C,B);
  2 Commenti
Mücahit Özalp
Mücahit Özalp il 19 Giu 2021
Modificato: Mücahit Özalp il 19 Giu 2021
@David Hill could you please delete your answer so that I can delete this topic the answer is not what I need?

Accedi per commentare.

Categorie

Scopri di più su Operating on Diagonal Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by