MATLAB: Undefined function ‘contains’ for input arguments of type ‘char’

MATLAB

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

Best Answer

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.