Filter löschen
Filter löschen

How to group elements of an array

3 Ansichten (letzte 30 Tage)
Nisha Rajiv
Nisha Rajiv am 28 Aug. 2012
I have a array of 1500 rows and 2 columns Now among the 1500 rows there are repetition of values like 5 100s 2 300 etc... now i need to group all these 100s such that i find the minimum value of column for this group. How to do that
  1 Kommentar
Friedrich
Friedrich am 28 Aug. 2012
Are you looking for the sort function? If not, can you post a small example matrix and the output you would like to get?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 28 Aug. 2012
try this is code, let A - your array with size 1500 x 2.
k = find(abs(A(:,2) - 100) < eps(100));
[val,idx0] = min(A(k,1));
out = [val,k(idx0)];
  1 Kommentar
Nisha Rajiv
Nisha Rajiv am 3 Sep. 2012
thank u so much. It was useful for me..

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

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