表示节点的matlab函数,在MATLAB中自动生成函数调用图

您可以使用gnovice注释中引用的其他答案的技术来获取A(B)对中的函数依赖关系列表,其中A调用B.然后安装

GraphViz并使用它来生成图表.您可以从Matlab创建.dot文件.

function createFunctionDependencyDotFile(calls)

%CREATEFUNCTIONDEPENDENCYDOTFILE Create a GraphViz DOT diagram file from function call list

%

% Calls (cellstr) is an n-by-2 cell array in format {caller,callee;...}.

%

% Example:

% calls = { 'foo','X'; 'bar','Y'; 'foo','Z'; 'foo','bar'; 'bar','bar'};

% createFunctionDependencyDotFile(calls)

baseName = 'functionCalls';

dotFile = [baseName '.dot'];

fid = fopen(dotFile, 'w');

fprintf(fid, 'digraph G {\n');

for i = 1:size(calls,1)

[parent,child] = calls{i,:};

fprintf(fid, ' "%s" -> "%s"\n', parent, child);

end

fprintf(fid, '}\n');

fclose(fid);

% Render to image

imageFile = [baseName '.png'];

% Assumes the GraphViz bin dir is on the path; if not, use full path to dot.exe

cmd = sprintf('dot -Tpng -Gsize="2,2" "%s" -o"%s"', dotFile, imageFile);

system(cmd);

fprintf('Wrote to %s\n', imageFile);

GraphViz适用于许多其他树和图形应用程序,如类继承和依赖关系树,数据流等.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值