我怎样才能"简介"只是我在MATLAB中的.m函数?

时间:2015-05-08 14:10:02

标签: matlab profile

我有一个相对较大的代码,我想使用" profile"改善它。当我使用" profile"我收到了一份报告,列出了所有功能(内置&。我和.m功能)及其各自的运行时间。

我想列出我自己编写的函数(不是内置函数)及其各自的运行时间。谁知道怎么做?

提前致谢。

2 个答案:

答案 0 :(得分:0)

您是否正在查看个人资料摘要?如果是这样,那么每个函数(包括您自己的函数)都会列出总时间自我时间的列。我认为自我时间可能是你正在寻找的时间。此外,您可以单击最左侧列中的函数名称,并查看代码中花费时间的详细信息。请务必检查显示功能列表框并刷新以查看代码每行的时序详细信息。我希望这会有所帮助。

答案 1 :(得分:0)

尝试使用profile函数的matlabroot参数。我通过将完整路径名称与profile on ... % Put the code to profile here % Stop the profiler and get infos stats = profile('info'); % Sort results based on the total execution time [~,I] = sort([stats.FunctionTable.TotalTime], 'descend'); for i = I % Get file structure F = stats.FunctionTable(i); % Discard Matlab functions if ~isempty(findstr(F.CompleteName, matlabroot)) continue; end % Display the total execution time and the function name fprintf('%.06f sec\t', F.TotalTime); fprintf('%s\n', F.FunctionName); end 进行比较来丢弃Matlab函数。这是代码:

repmat

虽然分析器提供的表示看起来更好,但这确实完成了您的目的。

NB :起初我以为我可以使用exist函数的输出,但只有Matlab函数的核心子集被标记为内置'。例如,verLessThantype具有与自定义函数相同的标志,因此不被视为内置函数。

最佳,