Contents Previous Next Subchapters

Determining Indices Where A Text Pattern Occurs
Syntax i = find(textpattern)
[ij] = find(textpattern)
See Also findstr , find nonzero , find characters , strreplace , string equality and string ordering

Returns the indices in the character matrix text at which there are occurrences of the pattern specified by the character row vector pattern. If both i and j are present, they are integer column vectors containing the row and column indices in text. Otherwise i is a two column integer matrix with the first column corresponding to row indices and the second to column indices. Trailing blanks in pattern are not ignored and must be matched.

If you enter
     list = {"TEST.FOR", "TEST.MAT", "WRITE.MAT", "WRITE.FOR"}
     find(list, ".MAT")
O-Matrix will respond
     [ 2 , 5 ]
     [ 3 , 6 ]