Lets say I have these 2 following matrix (which are not the same dimension):
A=[2 1 4 3 5 6] B=[5 4 3 1]
My goal is to find the following logical array:
A2=[1 0 0 0 0 1]
where 1 is the logical condition when a value in A is missing in B (again it must check the whole array B because dimension are not the same).
Thank you so much in advance for your answer !
Regards,
Pierre

 採用された回答

Star Strider
Star Strider 2017 年 10 月 28 日

0 投票

Use the ismember function and the logical negation ‘~’ operator:
A=[2 1 4 3 5 6];
B=[5 4 3 1];
A2 = ~ismember(A,B)
A2 =
1×6 logical array
1 0 0 0 0 1

2 件のコメント

Pierre Lonfat
Pierre Lonfat 2017 年 10 月 29 日
Works ! Thank you very much !
Star Strider
Star Strider 2017 年 10 月 29 日
As always, my pleasure!

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

その他の回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2017 年 10 月 28 日

1 投票

all(A(:)' ~= B(:))

1 件のコメント

Pierre Lonfat
Pierre Lonfat 2017 年 10 月 29 日
Works as well ! THANK YOU !!

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by