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

12 次查看(过去 30 天)
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?

回答(1 个)

Ameer Hamza
Ameer Hamza 2020-4-15
编辑:Ameer Hamza 2020-4-15
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

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by