Filter löschen
Filter löschen

Matlab Minimum

2 Ansichten (letzte 30 Tage)
athpapa -
athpapa - am 3 Mär. 2011
Hello,
If I have an array for example: A=[10 11 12 1 8 9 1 3 5] and I use the '[C,I]=min' function to find the minimum value of the array. But if the array has two or more same minimum values, the MIN function always return the first value!How can I get the last minimum value of an array?In my example, I want the 7th value 1 of array A and not the 4th.However, I want this function to work for random arrays and not only for array A.
Thank you..!!

Akzeptierte Antwort

Matt Tearle
Matt Tearle am 3 Mär. 2011
find(A==min(A))
will get them all. Then you can choose whichever you like. To get just the last one
find(A==min(A),1,'last')
  3 Kommentare
athpapa -
athpapa - am 3 Mär. 2011
I haven't seen your complete answer!Thank you..!!!:)
Andreas Goser
Andreas Goser am 3 Mär. 2011
Excellent! Didn't new that one.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (2)

Andreas Goser
Andreas Goser am 3 Mär. 2011
My rough idea is along the lines of sorting the vector first (with saving the indices) and then identify the last minimum.

David Young
David Young am 3 Mär. 2011
If you only want the last one, you could use
[v, ind] = min(A(end:-1:1));
ind = 1 + length(A) - ind;

Kategorien

Mehr zu Creating and Concatenating Matrices 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