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

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

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.

*No products are associated with this question.*

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;

## 3 Comments

## Image Analyst (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/77746#comment_152435

Why do you post this when you had a

better version of this questionalready posted at http://www.mathworks.com/matlabcentral/answers/77743-put-a-small-matrix-in-a-bigger-one 40 minutes earlier. Please don't duplicate questions. I already answered there for you.## Walter Roberson (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/77746#comment_152498

Duplicates http://www.mathworks.co.uk/matlabcentral/answers/77743-put-a-small-matrix-in-a-bigger-one

## the cyclist (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/77746#comment_152499

Walter's comment here http://www.mathworks.com/matlabcentral/answers/77746-small-matrix-in-big-matrix duplicates Image Analyst's comment here: http://www.mathworks.com/matlabcentral/answers/77746-small-matrix-in-big-matrix.

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