MATLAB: How to compare two sentences with similar words

strings

I have two string sentences with similar words, I want to know if there is a common word between them, case insensitive.
string1='Install peoplenet antenna';
string2='ANT-PMG,PEOPLENET,30';
So I want the answer to be 'true' or logical because 'peoplenet' is there in both the sentences.

Best Answer

First, split each sentence into the individual words
words_1 = split(string1,[" ",","]);
words_2 = split(string2,[" ",","]);
Then check if they share any words (comparing lowercase versions)
common_words = intersect(lower(words_1),lower(words_2))
share_words = ~isempty(common_words);
Related Question