remove rows under certain condition

조회 수: 3 (최근 30일)
booterr
booterr 2016년 4월 14일
편집: booterr 2016년 4월 14일
Can you help?
Can you help?
On below matrix, for same X and Y, pick smallest Z, then put into a new matrix.
X Y Z 60,-40,1.1 55,-40,3.1 55,-45,4.5 60,-45,5.3 60,-40,7 55,-40,8.4 55,-45,9.8 60,-40,11.2 60,-45,12.6 55,-40,14 55,-45,15.4 60,-45,16.8 60,-40,18.2 60,-45,19.6 55,-40,21 60,-40,22.4 55,-45,23.8 60,-45,25.2 55,-40,26.6 55,-45,28

채택된 답변

Jos (10584)
Jos (10584) 2016년 4월 14일
Assuming your X, Y, and Z variables are stored in three vectors of equal length
[UniqueXY, ~, k] = unique([X(:) Y(:)],'rows') ;
MinZ = accumarray(k, Z(:), [], @min)
  댓글 수: 1
booterr
booterr 2016년 4월 14일
편집: booterr 2016년 4월 14일
Can you put the same X and Y with corresponding min Z into new matrix by removing the rows?
and also give the row number for which row is kept.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by