How to insert a matrix into a matrix

This may sound like a bad question, but for a class I need to insert a matrix into a matrix. i.e. lets say that I have a 2x2 matrix [1 1; 1 1] and a 4x4 matrix [0 0 0 0; 0 0 0 0; 0 0 0 0; 0 0 0 0] and I want to insert the 2x2 matrix into the 4x4 matrix so that the resultant is [0 0 0 0; 0 0 0 0; 1 1 0 0; 1 1 0 0]. Obviously I have a different predefined values for the 2x2, but I cant figure out how to input them into the 4x4 matrix. Any help would be appreciated. Thanks.

回答 (1 件)

James Tursa
James Tursa 2016 年 11 月 11 日

2 投票

a = your 2x2 marix
b = your 4x4 matrix
b(3:4,1:2) = a;

2 件のコメント

Emma Feechan
Emma Feechan 2020 年 10 月 4 日
where do the numbers 3,4,1,2 come from in the answer?
Stephen23
Stephen23 2020 年 10 月 4 日
"where do the numbers 3,4,1,2 come from in the answer?"
From the requirements given in the question. The OP specified that the 2x2 matrix should be inserted into
  • rows three and four
  • columns one and two
of the 4x4 matrix. So those are the indices that correspond to what the OP requested.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeLinear Algebra についてさらに検索

質問済み:

2016 年 11 月 11 日

コメント済み:

2020 年 10 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by