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

 Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 21 Fév 2016
Modifié(e) : Azzi Abdelmalek le 21 Fév 2016
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]))'

Plus de réponses (1)

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 commentaires

DEHUA SHI
DEHUA SHI le 21 Fév 2016
I really appreciate your help
My pleasure!

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by