Borrar filtros
Borrar filtros

How can i know what is the n when the nth is the smallest or biggest

2 visualizaciones (últimos 30 días)
How can i know what is the n when the nth is the smallest or biggest,for example
A=[10 2 3 4 50]
mimn=min(A)
I can use the min instruction to know what is the smallest value in the vector A,but how do i know the nth element is 2 in the A vector,i mean i want to know the "n" value.In this simple example,we can know the "second" element is the smallest value in this A vector,but if there is 10000 elements in A vector,how do i know what is the n when the nth is the smallest ?

Respuesta aceptada

Rik
Rik el 29 de Mzo. de 2019
If you mean the index of the minimum value, the documentation for the min function shows you how to find the index. A different example vector will make it clearer.
A=[10 100 2 3 4 50];
[mimn,index]=min(A)
%mimn=2
%index=3
% so the third position has the lowest value in the vector, that value being 2

Más respuestas (1)

Andrei Bobrov
Andrei Bobrov el 29 de Mzo. de 2019
[minvalue, n] = min(A);

Categorías

Más información sobre Matrices and Arrays 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