I want to put a matrix A in another matrix B
example
A= 0 2 9
5 7 3
4 6 1
B= 0 2 9 0 0 0
5 7 3 0 0 0
4 6 1 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
and a C matrix in another place
C= 1 2 3
4 5 6
7 8 9
B= 0 2 9 0 0 0
5 7 3 0 0 0
4 6 1 0 0 0
0 0 0 1 2 3
0 0 0 4 5 6
0 0 0 7 8 9

 채택된 답변

Adam
Adam 2018년 11월 21일
편집: Adam 2018년 11월 21일

0 개 추천

A = [0 2 9; 5 7 3; 4 6 1];
C = [1 2 3; 4 5 6; 7 8 9];
B = zeros(6);
B(1:3,1:3) = A;
B(4:6,4:6) = C;

댓글 수: 2

dakhli mohamed
dakhli mohamed 2018년 11월 21일
I want to redo the same work but with a matrix of size 284 * 284
what should I do
Adam
Adam 2018년 11월 21일
Just extend it in the obvious way based on whatever you want to insert.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Guillaume
Guillaume 2018년 11월 21일

0 개 추천

Possibly, you're looking for blkdiag:
A = [0 2 9; 5 7 3; 4 6 1];
C = [1 2 3; 4 5 6; 7 8 9];
B = blkdiag(A, C)

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

제품

태그

질문:

2018년 11월 21일

답변:

2018년 11월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by