Overview of MATLAB Build Tool
The MATLAB® build tool is a build system that provides a standardized interface for defining and running build tasks, such as identifying code issues, running tests, and packaging a toolbox. To automate your builds, define your tasks in a build file and then run them by invoking the build tool programmatically or interactively.
Create Build File
Define tasks for your project by including a build file in your project root
folder. For example, in the Command Window, execute buildtool
-init to create a starter build file named
buildfile.m in your current folder.
buildtool -initThis code shows the contents of the build file. The build file contains tasks
created from built-in task classes in the matlab.buildtool.tasks namespace:
The
"clean"task deletes outputs and traces of the other tasks in the build file.The
"check"task identifies the code issues in the current folder and its subfolders and fails the build if any code errors are found.The
"test"task runs the tests in the current folder and its subfolders and fails the build if any of the tests fail.
function plan = buildfile import matlab.buildtool.tasks.* plan = buildplan(localfunctions); plan("clean") = CleanTask; plan("check") = CodeIssuesTask; plan("test") = TestTask; plan.DefaultTasks = ["check" "test"]; end
For more information on how to create tasks, see Create and Run Tasks Using Build Tool.
Run Tasks in Build File
You can run the tasks in your build file either programmatically or interactively.
For example, run the default tasks in the build file by using the buildtool command. Your results might vary, depending on the files
in your current folder and its subfolders.
buildtool
** Starting check
Analysis Summary:
Total Files: 3
Errors: 0 (Threshold: 0)
Warnings: 0 (Threshold: Inf)
** Finished check
** Starting test
...
Test Summary:
Total Tests: 3
Passed: 3
Failed: 0
Incomplete: 0
Duration: 0.44142 seconds testing time.
** Finished test
Build Successful:
2 Tasks: 0 Failed, 0 Skipped
17.774 sec total build timeFor information on how to run tasks interactively, see Run Build from Toolstrip. (since R2025a)
Enable Additional Capabilities with MathWorks Products
Certain MathWorks® products extend the capabilities of the MATLAB build tool. This table describes the additional use cases that the build tool covers when extended by other products.
| Product | Use Case | More Information |
|---|---|---|
| MATLAB Test™ |
|
|
| Simulink® Test |
|
|