How can I search for all occurrences of built-in MATLAB functions called from multiple .m and .mlx files?
Show older comments
I am teaching numerical methods with MATLAB, and the teaching material I have developed over time includes a vast number of MATLAB files (.m and .mlx) stored in a folder and its subfolders on my laptop.
I want to create a table listing all built-in MATLAB functions called in the code across these MATLAB files. Is there a way to search through all MATLAB files in a folder and its subfolders to identify and tabulate the MATLAB functions used? Ideally, I would like the result in a table format like this:
Function Files
----------------------------------------------
plot <filename_a1>, ..., <filename_an>
fprintf <filename_b1>, ..., <filename_bm>
...
----------------------------------------------
1 Comment
Walter Roberson
on 27 Nov 2024
Unfortunately, https://www.mathworks.com/help/matlab/ref/matlab.codetools.requiredfilesandproducts.html does not list built-in functions.
Accepted Answer
More Answers (1)
Image Analyst
on 27 Nov 2024
0 votes
You might try to get a list of functions by using dir() to find all m-files in all subfolders of your MATLAB installation folder. I'm not sure it will find all built-in functions though. It might find a lot of them though. Then loop over all of your own m-files written by you and open them up with something like fileread or readlines and search the contents of your custom written for each of the function names you found.
You might find the FAQ useful: Process a sequence of files
Categories
Find more on File Operations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!