Constructing a block diagonal matrix using the contents of a cell

2 visualizzazioni (ultimi 30 giorni)
Hi, I have created a structure which contains, say, four vectors of different lengths. So, for example:
AA=[98x1 double] [20x1 double] [98x1 double] [20x1 double]
I then use these vectors to pick out certain elements of a non-full matrix A, so, for instance (A(AA{1},AA{1}).
I was looking for a quick way to create a block diagonal matrix, with the entries, (A(AA{1},AA{1}) in the entry (1,1), (A(AA{2},AA{2})in the entry (2,2), (A(AA{3},AA{3}) in the entry (3,3) and (A(AA{4},AA{4}) in the entry (4,4) (ie: on the diagonals), with zeros obviously in the other positions. Is anyone aware of the best way to achieve this? I am unsure how to `tell' Matlab the dimension of the zero's in the block matrix, which will differ on an entry-by-entry basis.
Any help would be much appreciated.

Risposte (1)

Laura Proctor
Laura Proctor il 13 Dic 2011
I'm not quite sure of your end goal, the syntax "A(AA{1},AA{1}) in the entry (1,1)" isn't clear to me.
But, you may find the function blkdiag useful.

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