Borrar filtros
Borrar filtros

Simple question regarding sorting

1 visualización (últimos 30 días)
Mate 2u
Mate 2u el 28 de Jun. de 2012
Hi, If I have two column matrixes of size Nx1 and Mx1 and I want to marge them together to make a Yx1 Column, but sorted in order how would I do this? I would not want a repeate of a number also.

Respuesta aceptada

Wayne King
Wayne King el 28 de Jun. de 2012
Editada: Wayne King el 28 de Jun. de 2012
X = randi(30,100,1);
Y = randi(30,50,1);
Z = unique([X ; Y]);
The result from unique() is sorted.

Más respuestas (1)

Honglei Chen
Honglei Chen el 28 de Jun. de 2012
x = [1 3 5 7 9]'
y = [1 2 3 4 5]'
unique(sort([x;y]))

Categorías

Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by