Simple question regarding sorting

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.

 채택된 답변

Wayne King
Wayne King 2012년 6월 28일
편집: Wayne King 2012년 6월 28일

1 개 추천

X = randi(30,100,1);
Y = randi(30,50,1);
Z = unique([X ; Y]);
The result from unique() is sorted.

추가 답변 (1개)

Honglei Chen
Honglei Chen 2012년 6월 28일

0 개 추천

x = [1 3 5 7 9]'
y = [1 2 3 4 5]'
unique(sort([x;y]))

카테고리

도움말 센터File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

태그

질문:

2012년 6월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by