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)';

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by