How to extract different element between two cell array?

조회 수: 1 (최근 30일)
Aakriti Srivastava
Aakriti Srivastava 2022년 8월 5일
댓글: Aakriti Srivastava 2022년 8월 5일
I have two array
X1 = {'A','B','C','D'}
x2 = {'A','B','C','D','E','F','G','H'}
and I want to create a row having element not found in A i.e.
X3 ={ 'E','F','G','H'}

채택된 답변

Dave B
Dave B 2022년 8월 5일
편집: Dave B 2022년 8월 5일
How about using ismember combined with not (~)?
X1 = {'A','B','C','D'}
X1 = 1×4 cell array
{'A'} {'B'} {'C'} {'D'}
x2 = {'A','B','C','D','E','F','G','H'}
x2 = 1×8 cell array
{'A'} {'B'} {'C'} {'D'} {'E'} {'F'} {'G'} {'H'}
X3 = x2(~ismember(x2,X1))
X3 = 1×4 cell array
{'E'} {'F'} {'G'} {'H'}

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by