0

I am very new to Python, but I have experience with Matlab.

In my code I want to subscript 2D array using two 1D arrays as follows:

a=np.array([[1,2,3],[4,5,6],[7,8,9]])
patch=np.arange(2)
b = a [patch]
c= a[patch] [patch]

As a result, I want to have a 2x2 matrix: [(1, 2) (4, 5)]. Instead, my b and c are 2x3 matrices: b=c=[(1, 2, 3), (4,5,6)]

I was not able to solve it by myself. I know, that a[0:2,0:2] works, but in my code, I want to do it using predefined 1D arrays.

Thanks

3
  • Are you sure about : [(1, 2) (4, 6)]? Commented Apr 9, 2018 at 16:18
  • 1
    What's with the 6? Commented Apr 9, 2018 at 16:18
  • Sorry, I've edited the question Commented Apr 9, 2018 at 16:20

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.