0

How to manipulate an element of my choice in a multidimensional array in NumPy?

I have a matrix which consists five matrices. I like to change a particular element in the inner matrix.

15th May 2018, 9:53 PM
Soumyadip Ray
Soumyadip Ray - avatar
3 Antworten
+ 2
Hopefully, this makes it clearer. This has 5 matrices, each 2x2, and we are modifying a chosen element. If you were looking to access or manipulate it in a different way, please clarify and the example can be adjusted appropriately. https://code.sololearn.com/c76Xy0Q5tnrF
15th Jun 2018, 8:31 PM
1_coder
+ 1
Typically access is by row then column within your matrix. For example, in the following 3x3 matrix, you can access the last column of the second row as follows. import numpy as np ar = np.array([[1,2,3],[4,5,6],[7,8,9]]) print(ar[1][2]) If you have additional dimensions, they are indexed the same way: ar[0][1][2] is the last column of the second row in the first matrix.
14th Jun 2018, 1:52 AM
1_coder
0
I didn't get your point. please, elaborate again
15th Jun 2018, 11:45 AM
Soumyadip Ray
Soumyadip Ray - avatar