Using strcmpi, but still want to find start index of string (as in strfind)

2 views (last 30 days)
I have a series of files and I want to search the filenames to find the matching name, and then pull the data from the matching file. However, the name of one set of files start with the name of another set (like "filenames" for the first set and "filenames_part2" for the second set). When using strfind to search for the string filenames_part2, it returns the start index for filenames, since it just looks at the first part of the string. Tried using strcmp, but since the comparison only returns a T or F (1 or 0) rather than a start index it doesn't work right. It seems to go through the set and only use the first file to extract data from, since the program is written to look for a start index given by the strfind, which has now been replaced by the strcmp. Thus the program thinks the start index is always "1." Any tips on how to solve this issue? Basically I want to be able to search for an entire string and get a start index...
  1 Comment
Image Analyst
Image Analyst on 10 Nov 2011
And for your example "filenames" for the first file and "filenames_part2" for the second file, exactly what would you want the start index to be?

Sign in to comment.

Answers (0)

Categories

Find more on Characters and Strings in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!