find indices of a value in a particular row or column in relation to the full matrix

2 次查看(过去 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.

采纳的回答

Image Analyst
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 个)

类别

Help CenterFile Exchange 中查找有关 Numeric Types 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by