Last active
June 29, 2019 02:02
-
-
Save IamPhytan/d0dcc8535d775a33cb10f4a2ec4b7874 to your computer and use it in GitHub Desktop.
Batch file to run MATLAB files in a terminal or in the command prompt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| :: Run MATLAB scripts in CMD | |
| :: Usage Examples | |
| :: 'mat' is the name of my batch file | |
| :: mat myScript.m | |
| @echo off | |
| :: Get filename by removing extension | |
| set filename=%1 | |
| set filename=%filename:~0, -2% | |
| :: Output filename | |
| set out_file="output.txt" | |
| :: Run MATLAB | |
| "C:\Program Files\MATLAB\R2018a\bin\matlab.exe" -nosplash -nodesktop -wait -r "diary('%out_file%'); %filename%; diary off; exit" | |
| :: Show content of output file and delete it | |
| type %out_file% | |
| del %out_file% | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment