How do I extract the first ncolumns from a matrix, or how do i extract the columns from say, column 5 to column 5+n ?
The scenario is that I have a matrix, of dim=(i,j), then I want to look a contiguous blocks of column of length n.
So I want to look at the matrix from column0 to column n, then at column1 to column n+1. etc.
Until I reach the end of my matrix.
Thanks
>>> mat=array(range(0,20)).reshape(2,10)
>>> mat
array([[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
[10, 11, 12, 13, 14, 15, 16, 17, 18, 19]])
Given n=8.
I want to extract the first 8 columns.
Then the matrix from column [1,11] to column [8,18]
Then the matrix from column [2,12] to column [9,19]
1 Answer