check if the entries of an array exists in another array

218 次查看(过去 30 天)
I've got two arrays,
a1 = ["a", "b", "c", "d", "e", "f"]
a2 = ["c", "f"]
I would like to check if a2 is present in a1. For a dingle entry, I could use find. I'm not sure how to check for all entries of "a2" at once
Any suggestion on how to check?

采纳的回答

KSSV
KSSV 2020-8-30
编辑:KSSV 2020-8-30
Read about ismember.
[c,ia] = ismember(a1,a2) ;
a1(c)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by