MATLAB: How to use ‘OR’ within a ‘CONTAINS’ statement for a table

containsMATLABortable

Hi
Within the 2019b release of Matlab, how do I call in an 'OR' statement within a 'CONTAINS' statement with my data in a table?
Example:
HEARD (table column 1): 'the soft cushion broke the mans fall'
TARGET1 (table column 2); 'soft'
TARGET2 (table column 3): 'cushion'
TARGET3 (table column 4): 'broke'
TARGET4 (table column 5): 'man''s'
TARGET5 (table column 6): 'fall'
ALT1 (table column 7): 'mans'
I want Matlab to determine if the HEARD statement contains either TARGET4 or ALT1, and to return 1 for true
I have tried:
W4 = contains(Table{1,1},or(Table{1,5},Table{1,7}));
….and I have tried:
W4 = contains(Table{1,1},Table{1,5}|Table{1,7});
….and :
W4 = contains(Table{1,1},Table{1,5}||Table{1,7});
…but either I get an error message saying that '|' is an undefined operator for input arguments of type 'cell' or that the conversion to logical from cell is not possible.
Can anyone shed any light therefore on how to use contains( or ) with tables? Thanks.

Best Answer

W4 = contains(Table{1,1},Table{1,4}) | contains(Table{1,1},Table{1,7})
or
W4 = contains( Table{1,1} , Table{1,[4,7]} )