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

1 次查看(过去 30 天)
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 ?

采纳的回答

Rik
Rik 2019-3-29
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

更多回答(1 个)

Andrei Bobrov
Andrei Bobrov 2019-3-29
[minvalue, n] = min(A);

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by