Python Argmin function in MATLAB ( Finding an indexing in AxBxC array in specific colomn)
Afficher commentaires plus anciens
I have an matrix as dimensions 11x360x1360. I have to find the minimum indexes in each (11) column. In python i can do this operation with np.argmin(abs(x),axis = 0)). How can i do that in MATLAB? I have to search minimum index in 1x360x1360,2x360x1360 and my output should be 360x1360 and values in output should be 1,2,3,4,5,6,7,8,9,10,11('11' values).
Réponses (1)
Aditya Patil
le 22 Sep 2020
You can pass the linear option of the min function when you want to find the index of the minimum over multiple dimensions. Then use the ind2sub function to get subscript indices from the linear one's.
matrix = rand([11,360,1360]);
[value, index] = min(matrix, [], [2, 3], 'linear');
[I1, I2, I3] = ind2sub(size(matrix), index);
9 commentaires
Emre Can Ertekin
le 22 Sep 2020
Aditya Patil
le 23 Sep 2020
can you elaborate the issue you are facing?
Emre Can Ertekin
le 23 Sep 2020
Aditya Patil
le 24 Sep 2020
What version of MATLAB are you using?
Emre Can Ertekin
le 24 Sep 2020
Emre Can Ertekin
le 24 Sep 2020
Aditya Patil
le 25 Sep 2020
You can get the 360x1360 matrix by providing only the first dimension as such,
A(1,:,:)
If you want to change a specific value, then provide all three indices. You can also use the linear indices for this.
Emre Can Ertekin
le 25 Sep 2020
Aditya Patil
le 28 Sep 2020
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!