How can I determine which values in vector X are NOT in vector Y?

조회 수: 15 (최근 30일)
Lewis Foggie
Lewis Foggie 2020년 4월 6일
댓글: Birdman 2020년 4월 6일
Consider:
x = [10 20 30]
y = [10 5 20 30]
What's the simplest way you can think of to output a vector Z which tells you which vectors in y appear in x...
Z = [1 0 1 1]
So Z tells you that 10 appears in y and x, 5 appears in y but not x, 20 appears in y and x, 30 appears in y and x.

답변 (1개)

Birdman
Birdman 2020년 4월 6일
편집: Birdman 2020년 4월 6일
Z=~ismember(x,y)
It will return
0 0 0
which means every element in vector X are also in vector Y.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

제품


릴리스

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by