0
votes

I have a matrix (A) that is size 30x30 and I want to add it to a matrix of zeros of size 33x33 (B). I need the final matrix B to have A in the lower right corner of matrix B. How would I go about writing that into Matlab?

Thank you in advance.

2

2 Answers

1
votes

If you just want to replace the lower right part of B:

B(4:33,4:33) = A;

or if you really do want to add A to that part of B, as it says in your question title:

B(4:33,4:33) = B(4:33,4:33) + A;
0
votes

I guess you really need something like

B(4:33,4:33) = A;

Or:

B(4:33,4:33) = B(4:33,4:33) + A;

But perhaps also interesting:

B(end+1:end+30,end+1:end+30)=A

This can easily be adjusted to make for nice concatenations below or to the right.