Borrar filtros
Borrar filtros

How do I find/retrieve block in block matrix?

4 visualizaciones (últimos 30 días)
Clarisha Nijman
Clarisha Nijman el 11 de Ag. de 2018
Editada: Walter Roberson el 11 de Ag. de 2018
Hi,
let's say I have 3 matrices A,B,C and store them in a block diagonal matrix, such that I can refer easily to them in a for loop.
Example:
D=[A B C; B A B; C A B];
for j=1:3
for i=1:9
E=D(i,j)^1*x
end
end
If I say D(i,j) I get an entry of matrix D. But I want the block stored in the i-th row and the j-th column in de way D is defined in the example. D(1,2) should return matrix B and D(2,2) matrix A. How can I do this?
kind regards,
Clarisha

Respuestas (1)

Walter Roberson
Walter Roberson el 11 de Ag. de 2018
Editada: Walter Roberson el 11 de Ag. de 2018
In general you cannot, as you do not know that the matrices are the same size. If you knew the sizes of the matrices, you could calculate locations inside D given the block indices.
The better way to handle this is
D = {A B C; B A B; C A B};
then you would use D{1,2} to get back B, even if it is not the same size as the other matrices.

Categorías

Más información sobre Operating on Diagonal Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by