Borrar filtros
Borrar filtros

Locating Row and Column of Min. Value

2 visualizaciones (últimos 30 días)
Mark Coughlin
Mark Coughlin el 22 de Oct. de 2020
Respondida: KSSV el 22 de Oct. de 2020
Hi,
I am trying to find the first location where the minimum value is found. Below is my script so far:
x=[5 6 78 32;
34 1 7 2;
23 4 7 1];
k=min(x(:));
[row column]=find(x==k)
This script returns the row and column location of both minimums, however I just need to know the first.
Any help would be appreciated! Thankyou

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 22 de Oct. de 2020
Editada: Ameer Hamza el 22 de Oct. de 2020
[row column]=find(x==k,1)
%^ pass 1 here
Alternatively
x=[5 6 78 32;
34 1 7 2;
23 4 7 1];
[~, idx] = min(x, [], 'all', 'linear');
[r, c] = ind2sub(size(x), idx);

Más respuestas (1)

KSSV
KSSV el 22 de Oct. de 2020
[row column]=find(x==k,1)

Categorías

Más información sobre Environment and Settings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by