Strings of text are stored in MATLAB as vectors (single-row matrices). Individual characters in strings can be retrieved just as elements in a vector (e.g., stringname(4)). MATLAB also includes a number of commands to help you work with strings. Use the “strfind” command to search a string for a particular character or set of characters (substring). mystring = ‘This is an example string.’; strfind(mystring,‘i’) The numbers 3, 6 and 23 are returned in a vector. These numbers correspond to the indices in “mystring” where “i” was found (the third, sixth and 23rd letters). strfind(mystring,’example’) The number 12 is returned. This corresponds to the 12th character in the string, where the word “example” begins. Writer Bio

How to Find a Substring in MATLAB - 9