how do i create a block matrix and do operations with the specific blocks in it

12 visualizaciones (últimos 30 días)
so lets say i have a bunch of 2x2 matrix :a,b,c,d
and i want to put them in another matrix Q
how do i do that? and can i do operations with the blocks in q as standalone matrix in this way or not?

Respuestas (1)

Ameer Hamza
Ameer Hamza el 15 de Abr. de 2020
Editada: Ameer Hamza el 15 de Abr. de 2020
You can concatenate the matrices like this
a = [1 2; 3 4];
b = [4 5; 7 8];
c = [9 10; 11 12];
d = [13 14; 15 16];
Q = [a b; c d]; % this matrix is 4x4
To do operation on a block of Q, you can use indexing
Q(1:3, 1:3) = Q(1:3, 1:3)*2; % multiply top-left 3x3 block with 2
Read these for more details

Categorías

Más información sobre Creating and Concatenating 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