How to extract a vector from a vector given a reference vector ?

1 Ansicht (letzte 30 Tage)
RuiQi
RuiQi am 23 Dez. 2016
Beantwortet: KSSV am 23 Dez. 2016
I have a main vector = [1 1 1 1 2 3 4 5 7 8 8 8 2 2 1 1 1 .....] and a reference vector = [1 3 4 7 9 1312] how do i extract the vector in main whose value are in reference vector ?
so it should be [1 1 1 1 3 4 7]

Akzeptierte Antwort

KSSV
KSSV am 23 Dez. 2016
A = [1 1 1 1 2 3 4 5 7 8 8 8 2 2 1 1 1] ;
B = [1 3 4 7 9 13 12] ;
iwant = A(ismember(A,B))

Weitere Antworten (0)

Kategorien

Mehr zu Denoising and Compression finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by