Search code examples
matrixrowoctave

Make a matrix B of the first, fourth and fifth row and the first and fifth column from matrix A in OCTAVE


I have matrix A A =

 5    10    15    20    25
10     9     8     7     6
-5   -15   -25   -35   -45
 1     2     3     4     5
28    91   154   217   280

And i need to make a matrix B of the first, fourth and fifth row and the first and fifth column from matrix A. How can i do it?


Solution

  • >> B = A([1,4,5],[1,5])
    B =
     5      25
     1       5
    28     280
    

    You should look up how to use index expressions in the Matlab and Octave language to extract and work with submatrices.

    See the Octave help on Index expressions: https://octave.org/doc/latest/Index-Expressions.html