How to group elements of an array

조회 수: 1 (최근 30일)
Nisha Rajiv
Nisha Rajiv 2012년 8월 28일
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
Friedrich
Friedrich 2012년 8월 28일
Are you looking for the sort function? If not, can you post a small example matrix and the output you would like to get?

댓글을 달려면 로그인하십시오.

채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 8월 28일
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
Nisha Rajiv
Nisha Rajiv 2012년 9월 3일
thank u so much. It was useful for me..

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by