Undefined function 'contains' for input arguments of type 'char'

33 vues (au cours des 30 derniers jours)
JFz
JFz le 23 Jan 2017
Commenté : JFz le 23 Jan 2017
Hi,
I am trying to use contains to check if string A has string B in it. Say, A = 'XYZXYZ', B = 'XY', I am using: tf = contains(A, B); But I keep getting error "Undefined function 'contains' for input arguments of type 'char'" Why?
Thanks in advance for any help. Jennifer

Réponse acceptée

the cyclist
the cyclist le 23 Jan 2017
Modifié(e) : the cyclist le 23 Jan 2017
Are you using an older version of MATLAB? According to the documentation for contains, this function was introduced in version R2016b.
You might be able to use strfind instead.
  1 commentaire
JFz
JFz le 23 Jan 2017
Oh, I am using 2015b. OK. I will use strfind instead. Thanks.

Connectez-vous pour commenter.

Plus de réponses (1)

Geoff Hayes
Geoff Hayes le 23 Jan 2017
Jennifer - which version of MATLAB are you using? According to contains, this function was introduced in R2016b.
  2 commentaires
JFz
JFz le 23 Jan 2017
Thanks. I am using 2015b.
JFz
JFz le 23 Jan 2017
Thanks a lot Geoff. I am going to use strfind instead.

Connectez-vous pour commenter.

Catégories

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

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by