Like the "grep" functionality in the GNU Project, this program searches files for the presence of a search string. However, mfilegrep searches only mfiles. Searches can be recursive or non-recursive, and case-sensitive or non-case-sensitive, and can search for whole words or partial words. The result is returned in a cell array that contains the names of all mfiles on the specified path that contain the search string. Additionally, the user has the option of listing the text of all lines in the mfiles containing the search string.
Careful application of profile to mfilegrep found a spare call to intersect. Long searches spent 90% of their time in that one line. I've fixed that, and several other (minor) bugs in mgrep.
Great for cleaning up bigger applications, same name for same variables in all m-files.
Thank you, Brett, for this great routine. I find mfilegrep more convenient than dos('grep etc etc').
I omitted one of the possible input arguments in my descriptive comments.