How can I find which function in my path contains a specific variable?

Let's pretend I have 1000 functions in my path and I've forgotten which function contains the variable: "Waldo". Unfortunately for me only one of those functions contains Waldo. Is there a way to find Waldo without opening 1000 different functions and using control+F 1000 times?

 采纳的回答

I posted a tool on the FEX some time ago. It will search through your entire directory to find any string in any function.
>> mgrep 'Waldo' .
Searching directory(ies)...
>>
The . there is standard, telling it too start looking in the current directory. That search will be done in a recursive manner, looking inside any sub-directories if you allow it to do so.
I can try something more likely to have success on my system.
mgrep 'tridiagonal' .
Searching directory(ies)...
/Users/johnderrico/Desktop/My_FEX/BLKTRIDIAG/blktridiag.m
% computes a sparse (block) tridiagonal matrix with n blocks
% a - (n*p by n*q) sparse block tridiagonal array
% compute the simple 10x10 tridiagonal matrix, with 2 on the
% compute the 3x6 tridiagonal matrix, with non-square blocks
There you see it tells me what functions have a hit with that string, as well as in which lines it was found.
Sadly, there was no Waldo to be found in my toolboxes. I hope your own personal search for Waldo meets with success. :)
Find mgrep on the File Exchange.

更多回答(1 个)

You can do this from the Current Folder component of the Desktop or from the Home tab of the Toolstrip using the instructions on this documentation page.

类别

Community Treasure Hunt

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

Start Hunting!

Translated by