how in matrix insert other matrix
7 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
Razvan
on 22 May 2011
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 Comments
More Answers (1)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!