Find min in matrix given specific rows and columns?
Mostrar comentarios más antiguos
I have a matrix, A, and I want to find the minimum value given specified row and column vectors, r and c. I also want to return the col and row of that minimum value in A. Any idea how to find the min? Given A, r, and c, the answer for this scenario should be a min value of 1 because it is in row 1, col 1, which is a part of the r and c vectors.
A = [1 12 23 19 1 13;
2 3 13 34 5 75;
5 22 45 5 1 94;
4 5 68 2 5 17;
2 4 34 11 13 92];
r = [1 3 4];
c = [1 2 3];
Respuesta aceptada
Más respuestas (1)
Ganesh Hegade
el 1 de Ag. de 2017
You can use this.
minRow = min(min(A(r, :)));
minCol = min(min(A(:, c)));
1 comentario
Andrew Poissant
el 2 de Ag. de 2017
Categorías
Más información sobre Resizing and Reshaping Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!