Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Sorting 2 row columns

조회 수: 1 (최근 30일)
Lucas Berghmans
Lucas Berghmans 2017년 12월 6일
마감: MATLAB Answer Bot 2021년 8월 20일
I have two colums
for example
x=[0.5 0.8 0.9 0.9 0.9 1]
y=[2 1.8 1.6 1.5 1.2 1.1]
I want to obtain this result
x=[0.5 0.8 0.9 1]
y=[2 1.8 1.2 1.1]
The lowest y-value that occurs for the x-value (that occurs multiple times), needs to be sorted.

답변 (1개)

Guillaume
Guillaume 2017년 12월 6일
[x, ~, id] = unique(x);
y = accumarray(id, y, [], @min)';
  댓글 수: 1
KL
KL 2017년 12월 6일
+1! Simple and neat!

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by