This article compares the differences between the numpy of MATLAB and Python in terms of dimension indexes:
1, the starting point of the index is different: Matlab starting position index is 1,python 0
2. The parentheses of the index are different: elements in MATLAB can be indexed by parentheses, and Python uses brackets:
A (1, 2) in MATLAB represents the first row of a, and the elements of the second column
Python's numpy in A[1, 2] represents the second row of a, the element of the third column
A (:, 1) in MATLAB represents all elements of the first column of a
Python numpy in a[:, 1] represents all elements of a second column
Note: The last index of both is always the index of the column.
3, the default dimensions of the array are different: in Matlab, a one-dimensional array is a two-dimensional array with a second dimension of 1. In Python, A=np.arrange (10) produces a one-dimensional array, while a = Np.reshape (Np.arrange (10), (10, 1)) is a two-dimensional array with 10 rows and 1 columns. A = Np.reshape (Np.arrange (10), (1, 10)) is a two-dimensional array with 1 rows and 10 columns.
The order of dimensions in the numpy of Mathab and Python