Filter löschen
Filter löschen

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

2 Ansichten (letzte 30 Tage)
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.

Akzeptierte Antwort

Image Analyst
Image Analyst am 27 Apr. 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))

Weitere Antworten (0)

Kategorien

Mehr zu Numeric Types finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by