to combine different vectors with the same element

In matlab, which command can combine different vectors, and form a new vector like a boolean merge,for example, I have three vectors,[1 2 3 4], [2 4 5],[ 1 5 6],by using this command, a new vector [1 2 3 4 5 6]is formed, where only one of the same elements is left and these element are in series from small to large

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2016년 2월 21일
편집: Azzi Abdelmalek 2016년 2월 21일
out=union([1 2 3 4], union([2 4 5],[ 1 5 6]))
%or
out=union([],cat(2,[1 2 3 4], [2 4 5],[ 1 5 6]))'

추가 답변 (1개)

Star Strider
Star Strider 2016년 2월 21일
A completely unique experience:
three_vectors = [[1 2 3 4], [2 4 5],[ 1 5 6]];
new_vector = unique(three_vectors)
new_vector =
1 2 3 4 5 6

댓글 수: 2

I really appreciate your help
My pleasure!

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

질문:

2016년 2월 21일

댓글:

2016년 2월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by