Define a $2 \times 2$ matrix that is the lower $2 \times 2$ block in $A$ (Matlab)

72 Views Asked by At

First of all, on this Matlab exercise sheet that I am currently working through what does the term 'the lower $2 \times 2$ block' mean in the question below?

$A = \left[\begin{array}\ 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ \end{array}\right]$,

Define a $2 \times 2$ matrix that is the lower $2 \times 2$ block in $A$.

2

There are 2 best solutions below

0
On BEST ANSWER

It is clear from the wording; it is the submatrix $\left[\begin{array}\ 5 & 6 \\ 8 & 9 \\ \end{array}\right]$. In Matlab, you need to say $A(2:3,2:3)$ to get the submatrix.

0
On

If the size of A can vary, you can always get the lower 2x2 block as such:

A(end-1:end,end-1:end)

Note that this always works as long as the width and height of A are both at least 2.