For example I ask in a question to write a function to take in an input which is a vector and return a scaler which is the sum of all the vector elements. This can be done using for loops. But let's say I don't want someone to use the inbuilt function sum. How do I check if a specific .m file contains inbuilt functions like sum or max?
1 Answer
If you want to check if a certain name name refers to a built-in function in your current path, use exist( 'name', 'file' ) == 5.
If you want to list all the built-in dependencies within a matlab file, use the second output of depfun. For example if I want to check if file foo.m uses the built-in function bar, I could do:
[~,builtin_dep] = depfun('foo.m','-quiet');
ismember( 'bar', builtin_dep )