在命令行下運行Matlab

2014-04-20 22:08:11java

在命令行下執行:node

matlab -help

能夠獲得幫助文件:windows

Usage:  matlab [-h|-help] | [-n | -e]
               [-arch | v=variant | v=arch/variant]
               [-c licensefile] [-display Xdisplay | -nodisplay]
               [-nosplash] [-mwvisual visualid] [-debug] [-softwareopengl]
               [-desktop | -nodesktop | -nojvm]
               [-r MATLAB_command] [-logfile log]
               [-Ddebugger [options]]

-h|-help             - Display arguments.
-n                   - Display final environment variables,
                       arguments, and other diagnostic
                       information. MATLAB is not run.
-e                   - Display ALL the environment variables and
                       their values to standard output. MATLAB
                       is not run. If the exit status is not
                       0 on return then the variables and values
                       may not be correct.
-arch                - Start MATLAB assuming architecture arch.
v=variant            - Start the version of MATLAB found
                       in bin/glnxa64/variant instead of bin/glnxa64.
v=arch/variant       - Start the version of MATLAB found
                       in bin/arch/variant instead of bin/glnxa64.
-c licensefile       - Set location of the license file that MATLAB
                       should use.  It can have the form port@host or
                       be a colon separated list of license files.
                       The LM_LICENSE_FILE and MLM_LICENSE_FILE
                       environment variables will be ignored.
-display Xdisplay    - Send X commands to X server display, Xdisplay.
-nodisplay           - Do not display any X commands. The MATLAB
                       desktop will not be started. However, unless
                       -nojvm is also provided the Java virtual machine
                       will be started.
-nosplash            - Do not display the splash screen during startup.
-mwvisual visualid   - The default X visual to use for figure windows.
-debug               - Provide debugging information especially for X
                       based problems.
-desktop             - Allow the MATLAB desktop to be started by a
                       process without a controlling terminal. This is
                       usually a required command line argument when
                       attempting to start MATLAB from a window manager
                       menu or desktop icon.
-nodesktop           - Do not start the MATLAB desktop. Use the current
                       terminal for commands. The Java virtual machine
                       will be started.
-singleCompThread    - Limit MATLAB to a single computational thread. 
                       By default, MATLAB makes use of the multithreading 
                       capabilities of the computer on which it is running.
-nojvm               - Shut off all Java support by not starting the
                       Java virtual machine. In particular the MATLAB
                       desktop will not be started.
-jdb [port]          - Enable remote Java debugging on port (default 4444)
-r MATLAB_command    - Start MATLAB and execute the MATLAB_command.
-logfile log         - Make a copy of any output to the command window
                       in file log. This includes all crash reports.
-Ddebugger [options] - Start debugger to debug MATLAB.
-nouserjavapath      - Ignore custom javaclasspath.txt and javalibrarypath.txt files.

能夠看到與圖形界面相關的幾個參數是:nodisplay, nosplash, nodesktop, nojvm. 它們分別表明什麼含義呢?bash

  1. nodisplay      不顯示任何X命令(X server是Linux下的圖形引擎,參考:X Window System)。Matlab桌面環境不會啓動,可是會啓動Java virtual machine除非使用了nojvm參數;
  2. nosplash   程序啓動時不顯示啓動畫面(版權頁);
  3. nodesktop  不啓動桌面環境,在當前終端中執行命令,可是會啓動JVM;
  4. nojvm      關閉java支持,不啓動JVM,特別的,desktop也不會啓動。

由於Matlab的圖形環境依賴JVM,若是不啓動JVM,沒法執行任何和圖形界面相關的命令。若不執行任何X commands,則沒法執行imshow()這些函數。因此,咱們若是須要在命令行下執行matlab程序,最好只添加:nodesktop nosplash兩個參數。less

能夠在文件.bashrc中添加:jvm

alias mrun="matlab -nodesktop -nosplash -logfile `date +%Y_%m_%d-%H_%M_%S`.log -r"

其中,logfile `date +%Y_%m_%d-%H_%M_%S`.log 將log文件輸出在了以程序執行時間爲文件名的log文件下。r 參數表示運行matlab命令。ide

相關文章
相關標籤/搜索