Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Sorting 2 row columns

1 visualización (últimos 30 días)
Lucas Berghmans
Lucas Berghmans el 6 de Dic. de 2017
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
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.

Respuestas (1)

Guillaume
Guillaume el 6 de Dic. de 2017
[x, ~, id] = unique(x);
y = accumarray(id, y, [], @min)';
  1 comentario
KL
KL el 6 de Dic. de 2017
+1! Simple and neat!

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by