필터 지우기
필터 지우기

Simple question regarding sorting

조회 수: 1 (최근 30일)
Mate 2u
Mate 2u 2012년 6월 28일
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일
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일
x = [1 3 5 7 9]'
y = [1 2 3 4 5]'
unique(sort([x;y]))

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by