find indices of a value in a particular row or column in relation to the full matrix
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Image Analyst
2017-4-27
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multidimensional Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!