To create a new 2 x 2 matrix c
by extracting the corner values of matrix a
in MATLAB, you can use indexing.
Here is an example code to achieve this:
main.m146 chars9 lines
This code creates a 3 x 3 matrix a
, and then extracts the corner values using indexing. a([1,end],[1,end])
selects the first and last rows, and the first and last columns of matrix a
, creating a new 2 x 2 matrix c
containing the corner values.
The result will be:
main.m10 chars3 lines
In this example, the corner values are 1, 3, 7, and 9.
gistlibby LogSnag