Searching for a literal substring
Problem
You want to find out whether a string contains a particular string inside of it.
Solution
The function strfind() will return the indices of the beginning of each occurance of a substring.
strfind('foobar bar','bar') % 4 8
Since an array containing all nonzero values is treated as true by if, you can do things like this:
string = 'this string has a ring'; pattern = 'ring'; if strfind(string, pattern) disp(['Found a ' pattern]); end