check if the entries of an array exists in another array

238 vues (au cours des 30 derniers jours)
Deepa Maheshvare
Deepa Maheshvare le 30 Août 2020
Modifié(e) : KSSV le 30 Août 2020
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?

Réponse acceptée

KSSV
KSSV le 30 Août 2020
Modifié(e) : KSSV le 30 Août 2020
Read about ismember.
[c,ia] = ismember(a1,a2) ;
a1(c)

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by