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 日

0 投票

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'}

1 件のコメント

Aakriti Srivastava
Aakriti Srivastava 2022 年 8 月 5 日
Sure I havent thought about that works well. Thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Code Generation についてさらに検索

製品

リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by