Main Content

matlab.buildtool.TaskInputs Class

Namespace: matlab.buildtool

Container for task inputs

Since R2023b


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

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

  • To add or modify an input, use the inputs.InputName = value syntax, where InputName is the name of the input you want to add or modify.

  • To return an input, use the value = inputs.InputName syntax, where InputName is the name of the input whose value you want to return.

Class Attributes


For information on class attributes, see Class Attributes.



inputs = matlab.buildtool.TaskInputs creates a TaskInputs object that has no inputs.


inputs = matlab.buildtool.TaskInputs(name1,value1,...,nameN,valueN) creates a TaskInputs object with the specified input names and values.

Input Arguments

expand all

Task input 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 input value, specified as a value of any data type.


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