I am a newbie in python and got python-code to translate into Matlab for my work. I have a specific problem:
I've got a matrix with size for example (rows/columns/3rd dim) = (3/4/2).
A = array([[[1, 56, 0, 6],[5, 9, 10, 3],[50, 51, 59, 64]],[[2, 6, 4, 3],[10, 80, 53, 6],[12, 5, 36, 15]]])
For this matrix (and others) I have given the function
B = A.argmin(axis=-1)
which searches for the index of the minimum in every row. (numpy.argmin Manual)
B is in this case:
B = array([[2, 3, 0],[0, 3, 1]])
and of size (rows/columns) = (2/3).
My ame is to convert exactly this into a Matlab-version, so that I get exactly this matrix, but in Matlab ([Min Matlab Manual][2])
[~,B] = min(A,[],2)
gives me a matrix of size (row/colums/3rd dim) = (3/1/2). Matlab Output
The indices of the minimum in each row are the same, if one regard that python starts indexing at 0 and matlab at 1. The problem is the order of the matrix.
How do I get the indeces of the minimum of each row in exact the order as python does it in matlab?
I tried a lot with permute and vertcat, but this didn't work out and in the end it has to work for really big matrices.
I would be pleased, if someone could help me. Thanks in advance!