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

11 ビュー (過去 30 日間)
jess Nimbl
jess Nimbl 2020 年 4 月 15 日
編集済み: Ameer Hamza 2020 年 4 月 15 日
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 Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by