|
| 1 | +# Run MATLAB® Command |
| 2 | + |
| 3 | +This action executes a MATLAB script, function, or statement using the _first_ |
| 4 | +MATLAB version on the runner's system `PATH`. |
| 5 | + |
| 6 | +MATLAB exits with exit code 0 if the specified script, function, or statement |
| 7 | +executes successfully without error. Otherwise, MATLAB terminates with a nonzero |
| 8 | +exit code, which causes the build to fail. You can use the |
| 9 | +[`assert`](https://www.mathworks.com/help/matlab/ref/assert.html) or |
| 10 | +[`error`](https://www.mathworks.com/help/matlab/ref/assert.html) functions in |
| 11 | +the command to ensure that builds fail when necessary. When you use this task, |
| 12 | +all of the required files must be on the MATLAB search path. |
| 13 | + |
| 14 | +## Usage |
| 15 | + |
| 16 | +You can use this action `with`: |
| 17 | +| Argument | Description | |
| 18 | +|-----------|-------------| |
| 19 | +| `command` | (Required) Script, function, or statement to execute. <br/> If the value of `command` is the name of a MATLAB script or function, do not specify the file extension. If you specify more than one MATLAB command, use a comma or semicolon to separate the commands. <br/> **Example**: `myscript` <br/> **Example**: `results = runtests, assertSuccess(results);` |
| 20 | + |
| 21 | +### Using a GitHub-hosted runner? |
| 22 | +If you are using a GitHub-hosted runner, you can use the [Set up MATLAB action](https://github.com/mathworks/setup-matlab-action/) to install MATLAB on the runner. |
| 23 | + |
| 24 | +## Example |
| 25 | + |
| 26 | +```yaml |
| 27 | +name: Sample workflow |
| 28 | +on: [push] |
| 29 | + |
| 30 | +jobs: |
| 31 | + my-job: |
| 32 | + name: Say hello from MATLAB |
| 33 | + runs-on: ubuntu-latest |
| 34 | + steps: |
| 35 | + # Set up MATLAB using this action first if running on a GitHub-hosted runner! |
| 36 | + - uses: mathworks/setup-matlab-action@v0 |
| 37 | + |
| 38 | + - name: Run "disp('hello world')" directly using MATLAB |
| 39 | + uses: mathworks/run-matlab-command-action@v0 |
| 40 | + with: |
| 41 | + command: disp('hello world') |
| 42 | +``` |
| 43 | +
|
| 44 | +## See also |
| 45 | +- [Set up MATLAB action](https://github.com/mathworks/setup-matlab-action/) |
| 46 | +- [Run MATLAB Tests](https://github.com/mathworks/run-matlab-tests-action/) |
| 47 | +- [Continuous Integration - MATLAB & Simulink](https://www.mathworks.com/solutions/continuous-integration.html) |
| 48 | +
|
| 49 | +## Contact Us |
| 50 | +If you have any questions or suggestions, please contact MathWorks® at continuous-integration@mathworks.com. |
0 commit comments