Main Content

batchStartupOptionUsed

Determine if MATLAB started with -batch option

Description

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.

example

Examples

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");
else
    answer = 10;
end

Version History

Introduced in R2019a

See Also

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