how in matrix insert other matrix

조회 수: 14 (최근 30일)
Modestas Sekreckis
Modestas Sekreckis 2011년 5월 22일
hi how in matrix insert other matrix? for example I have:
A=repmat(2, [6 6]);
B=repmat(1, [4 4]);
How I can insert B to A and get it:
A=
2 2 2 2 2 2
2 1 1 1 1 2
2 1 1 1 1 2
2 1 1 1 1 2
2 1 1 1 1 2
2 2 2 2 2 2

채택된 답변

Razvan
Razvan 2011년 5월 22일
Try
[r,c]=size(B);
xpos=2;ypos=2;
A(xpos:xpos+r-1,ypos:ypos+c-1)=B;
, where xpos and ypos are the positions where you want to insert matrix B.
  댓글 수: 4
Modestas Sekreckis
Modestas Sekreckis 2011년 5월 22일
but I forgot to say one small detail, I use a 3D matrix in a real program. How then does it work?
Razvan
Razvan 2011년 5월 22일
[x,y,z]=ind2sub(size(A),find(A==1));

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

추가 답변 (1개)

Ben Mitch
Ben Mitch 2011년 5월 22일
A(2:5,2:5) = B;

카테고리

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