Technical Solutions
How do I call MATLAB from the DOS prompt?
Date Last Modified: Monday, January 18, 2010
| Solution ID: | 1-16B8X | |
| Product: | MATLAB | |
| Reported in Release: | No Release | |
| Platform: | Windows | |
| Operating System: | Windows Any |
Subject:
How do I call MATLAB from the DOS prompt?
Problem Description:
I would like to call MATLAB from the DOS prompt without opening it, and have it return a specific output file.
Solution:To start MATLAB from a DOS window running inside Windows, do the following: 2. Insert $MATLABROOT\bin into the path in the autoexec.bat file. (where $MATLABROOT is the MATLAB root directory on your machine, as returned by typing
matlabroot
at the MATLAB Command Prompt.)Now you can type <mat> at the dos prompt and Windows will come up with MATLAB. You can run MATLAB from the DOS prompt and save the session to an output file by doing the following: Depending on the directory you are in, you may need to specify the path to the executable. The MATLAB file you want to run must be on your path or in the directory. This MATLAB file can be a function that takes arguments or a script. When running a script 'myfile.m', use the following command:
When calling a function 'myfile.m' which accepts two arguments:
Note that the logfile will contain everything that was displayed to the Command Window while the MATLAB file was running. If you want to generate any print files you need to do this in the MATLAB file. You can combine this example with the above one to create a batch file that takes input files and creates output files. In addition, this will call up an additional instance of the MATLAB command window. If you wish this to exit after the computation is complete, you will need to add the command 'exit' to the end of your MATLAB file. You can suppress the splash screen by adding the -nosplash flag to the above command so it looks like the following: Although you cannot prevent MATLAB from creating a window when starting on Windows systems, you can force the window to be hidden, by using the start command with the -nodesktop and -minimize options together: Note: Batch files can be called from Windows scheduler in order to run MATLAB commands at specific times. |
|
|
Store

