MATLAB Answers


small matrix in big matrix

Asked by Ayob
on 2 Jun 2013

I want to put a small matrix (p*q) called B into a bigger matrix (m*n) called A. How can I do it. Matrix B should be put on the left-right corner of matrix A.


Why do you post this when you had a better version of this question already posted at 40 minutes earlier. Please don't duplicate questions. I already answered there for you.

Walter's comment here duplicates Image Analyst's comment here:

[Sorry. Couldn't resist teasing the master!]


No products are associated with this question.

1 Answer

Answer by the cyclist
on 2 Jun 2013
 Accepted answer

I don't know what "left-right corner" means, but in general you can do this as:

A = magic(7);
B = magic(3);
A(2:4,3:5) = B;


Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!