Main Content


Determine if MATLAB started with -batch option



batchStartupOptionUsed returns true when MATLAB® starts with -batch option. Otherwise, the function returns false. Use the -batch option to start MATLAB non-interactively.

Use this function to guard code from being executed when MATLAB is running non-interactively with the -batch startup option and user input is either not desired or not supported in this mode.


collapse all

Suppose that you have a test that requires user input. You can automate this test to run using the matlab -batch startup option.

Prompt the user for input during interactive testing or specify a default value for automated testing.

if ~batchStartupOptionUsed
    answer = inputdlg("Enter a number");
    answer = 10;

See Also

| | | (MATLAB Compiler SDK) | (MATLAB Compiler)

Introduced in R2019a