log used function names in a MATLAB program
1 次查看(过去 30 天)
显示 更早的评论
I want to log the name of all the functions that are called for each Object instance in MATLAB!
For example if we have this class:
classdef ClassName
methods
function obj = ClassName()
...
end
function ordinaryMethod()
...
end
end
end
And i run the following code:
testObj = ClassName();
testObj.ordinaryMethod();
I can somehow log that the ordinaryMethod was called for testObj which is a instance of ClassName. To make it clear, I dont want to just get a list of all the function names, I only need those that are used in my program.
Can anyone give me ideas, how i can achieve this? Ideal solution is that I don't have to change the function codes!
0 个评论
采纳的回答
Guillaume
2016-9-22
编辑:Guillaume
2016-9-22
You could simply use the profiler which will return the list of all functions called by your code (when you run it), then filter that list by the class name:
profile('on'); %starts the profiler
%run your code
p = profile('info'); %stops the profiler
allfunctions = vertcat(p.FunctionName);
classfunctions = allfunctions(strncmp(allfunctions, 'ClassName>', numel(className))) %omly keep ClassName methods
2 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Software Development Tools 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!