Main Content

matlab.buildtool.TaskOutputs Class

Namespace: matlab.buildtool

Container for task outputs

Since R2023b


The matlab.buildtool.TaskOutputs class provides a container for defining and grouping outputs of a task. For more information about task inputs and outputs, see Improve Performance with Incremental Builds.

A TaskOutputs object behaves like a structure, where field names are task output names and field values are task output values. To add, modify, or return a task output, index into the TaskOutputs object by using the output name:

  • To add or modify an output, use the outputs.OutputName = value syntax, where OutputName is the name of the output you want to add or modify.

  • To return an output, use the value = outputs.OutputName syntax, where OutputName is the name of the output whose value you want to return.

Class Attributes


For information on class attributes, see Class Attributes.



outputs = matlab.buildtool.TaskOutputs creates a TaskOutputs object that has no outputs.


outputs = matlab.buildtool.TaskOutputs(name1,value1,...,nameN,valueN) creates a TaskOutputs object with the specified output names and values.

Input Arguments

expand all

Task output name, specified as a string scalar or character vector. The name must be a valid MATLAB® identifier. A valid MATLAB identifier is a string scalar or character vector of alphanumerics (A–Z, a–z, 0–9) and underscores, where the first character is a letter and the length of the text is not greater than namelengthmax.

Task output value, specified as a array.


expand all


collapse all

Create a task that uses two named inputs to analyze program files and two named outputs to store the lists of files and products required to run the program files.

Open the example and then navigate to the named_io_example folder, which contains a build file.

cd named_io_example

This code shows the contents of the build file. The build file has a task that analyzes program files and stores the lists of files and products required to run the program files:

  • To specify the program files and the mode of the dependency analysis, the task uses the inputs named FilesToAnalyze and IncludeIndirectDependencies. The Inputs property of the task is a TaskInputs object that contains the named inputs.

  • To specify where to write the lists of required files and products, the task uses the outputs named FileList and ProductList. The Outputs property of the task is a TaskOutputs object that contains the named outputs.

function plan = buildfile
plan = buildplan(localfunctions);

% Specify the program files to analyze and whether to include indirect dependencies
plan("dependencies").Inputs.FilesToAnalyze = files(plan,"source/**/*.m");
plan("dependencies").Inputs.IncludeIndirectDependencies = false;

% Specify where to write the lists of required files and products
plan("dependencies").Outputs.FileList = files(plan,"fileList.txt");
plan("dependencies").Outputs.ProductList = files(plan,"productList.txt");

function dependenciesTask(context)
% Determine required files and products
files = context.Task.Inputs.FilesToAnalyze.paths;

if context.Task.Inputs.IncludeIndirectDependencies
    [fList,pList] = matlab.codetools.requiredFilesAndProducts(files);
    [fList,pList] = matlab.codetools.requiredFilesAndProducts(files,"toponly");


Run the "dependencies" task. The task analyzes the code in the source folder and any of its subfolders, and writes the lists of the required files and products to separate text files.

buildtool dependencies
** Starting dependencies
** Finished dependencies

Run the task again. The build tool skips the task because none of the inputs or outputs of the task have changed since the last run.

buildtool dependencies
** Skipped dependencies: up-to-date

Add a file to the source folder, and then rerun the task. The build tool runs the task because one of the inputs of the task has changed between consecutive builds.

buildtool dependencies
** Starting dependencies
** Finished dependencies

Version History

Introduced in R2023b