find indices of a value in a particular row or column in relation to the full matrix
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Morgan Clendennin
el 26 de Abr. de 2017
Respondida: Image Analyst
el 27 de Abr. de 2017
Hi,
I am trying to find the location of the max and min values of the first row and last column of an array. Let's say I have the following matrix: A=[1,2,3,4,5;,6,7,8,9,10;11,12,13,14,15;16,17,18,19,20;21,22,23,24,25]. I want to find the location of the max and min values in the first row and last column. By looking at this matrix we can easily see that it is the first number (or x = 1, y = 1,assuming that x is columns and y is rows), the last number in the first row (x = 5, y = 1) and the last number in the last column (x = 5, y = 5). My question is if we are using the find command to find the max and min in particular rows and columns, is how to relate this location in the column or row to the larger array.
0 comentarios
Respuesta aceptada
Image Analyst
el 27 de Abr. de 2017
Why use find() when min() and max() are more directly suited for finding the min and max values and indexes:
A=[1,2,3,4,5;,6,7,8,9,10;11,12,13,14,15;16,17,18,19,20;21,22,23,24,25]
[firstRowMaxValue, firstRowMaxIndex] = max(A(1, :))
[firstRowMinValue, firstRowMinIndex] = min(A(1, :))
[lastColMaxValue, lastColMaxIndex] = max(A(:, end))
[lastColMinValue, lastColMinIndex] = min(A(:, end))
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Multidimensional Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!