Filter löschen
Filter löschen

find N number of min values

1 Ansicht (letzte 30 Tage)
Panayiotis Christodoulou
Panayiotis Christodoulou am 31 Mai 2016
Bearbeitet: Andrei Bobrov am 31 Mai 2016
Hi there,
I have a dataset:
10 11 5 6 23 4 1 3 98 56
I want to find the 3 smallest values that exist in the dataset without replacing data from the original dataset as well their indices.
final result would be: Row,Value 7,1 8,3 6,4

Antworten (3)

Andrei Bobrov
Andrei Bobrov am 31 Mai 2016
Bearbeitet: Andrei Bobrov am 31 Mai 2016
s = [10
11
1
5
6
3
23
4
1
3
98
56];
[a,b] = unique(s,'first');
out = [b,a];
out = out(1:3,:);

KSSV
KSSV am 31 Mai 2016
  2 Kommentare
Panayiotis Christodoulou
Panayiotis Christodoulou am 31 Mai 2016
hi there,
i have a 10x1 matrix array and i want to find the 3 min values not just the 1.
KSSV
KSSV am 31 Mai 2016
Read the documentation of the function.....that can be done....

Melden Sie sich an, um zu kommentieren.


KSSV
KSSV am 31 Mai 2016
Alternatively you can sort them in ascending order and pick first three..
[val,pos] = sort(yourVector)

Kategorien

Mehr zu Shifting and Sorting 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