Main Content

plot

对计划中的任务绘图

自 R2022b 起

说明

示例

plot(plan) 将计划中的任务绘制为一个依存关系图,其中节点表示任务,边表示依存关系。图中的边从依赖任务流向被依赖任务。

该图将计划可视化为有向无环图。它不能包含任何循环。

输入参数

全部展开

计划,指定为 matlab.buildtool.Plan 对象。

示例

全部展开

将编译计划中的任务绘制为依存关系图。

打开该示例,然后导航到 plot_plan_example 文件夹,其中包含编译文件。

cd plot_plan_example

以下代码显示编译文件的内容。

function plan = buildfile
import matlab.buildtool.tasks.CodeIssuesTask
import matlab.buildtool.tasks.TestTask

% Create a plan from task functions
plan = buildplan(localfunctions);

% Add the "check" task to identify code issues
plan("check") = CodeIssuesTask;

% Add the "test" task to run tests
plan("test") = TestTask;

% Make the "archive" task the default task in the plan
plan.DefaultTasks = "archive";

% Make the "archive" task dependent on the "check" and "test" tasks
plan("archive").Dependencies = ["check" "test"];
end

function archiveTask(~)
% Create ZIP file
filename = "source_" + ...
    string(datetime("now",Format="yyyyMMdd'T'HHmmss"));
zip(filename,"*")
end

从编译文件中加载一个计划。

plan = buildfile
plan = 
  Plan with tasks:

    archive - Create ZIP file
    check   - Identify code issues
    test    - Run tests

将该计划中的任务绘制为一个依存关系图。该图将任务显示为节点。由于 "archive" 任务依赖 "check""test" 任务,因此该图还包含表示这些依存关系的两条边。

plot(plan)

Figure contains an axes object. The axes object contains an object of type graphplot.

版本历史记录

在 R2022b 中推出