How do I extract from a matrix rows and columns that are not consecutive. For example, in this matrix how do i extract rows 1,2 and 4 with columns 1, 2 and 4?
import numpy as np
a = np.matrix([[1, 2, 3, 4, 5],
[6, 7, 8, 9, 10],
[11, 12, 13, 14, 15],
[16, 17, 18, 19, 20],
[18, 19, 20, 21, 22]])
So the new matrix should be:
b = ([[7, 8 , 10],
[12, 13, 15],
[19, 20, 22]])
source https://stackoverflow.com/questions/71443487/how-to-extract-non-consecutive-rows-and-columns-of-a-matrix
Comments
Post a Comment