ColeS - 8 months ago 37

Python Question

I have created an m-by-n matrix in MATLAB and can easily select a range of values within a certain column and row. For instance, if I have matrix

`A`

`A =`

0 0 0 0

1 2 3 4

5 6 7 8

9 10 11 12

I can isolate the values: 1,5 and 9 from the first column by typing:

`A(2:4,1)`

`[1;5;9]`

Answer

This can be done using numpy

`a = numpy.matrix('0 0 0 0; 1 2 3 4; 5 6 7 8; 9 10 11 12')`

Required result is `a[1:,0]`

or `a[1:4,0]`

Only difference is that the array indexing start from 0 instead of 1.