Determine whether code is running in deployed or MATLAB mode
x = isdeployed returns logical 1 (
when the function is running in deployed mode using MATLAB® Runtime and 0 (
false) if it is running in a MATLAB session.
An application running in deployed mode consists of a collection of MATLAB functions and data packaged using MATLAB Compiler™ into software components that run outside a MATLAB session using MATLAB Runtime libraries.
Access Files from Deployed Functions
You can access files included in a packaged application by
which function, or by specifying the file location
Add a file such as
extern_app.exe to your MATLAB
Check if the code is running in deployed mode by using
isdeployed. Then, obtain the path to the file by
if isdeployed locate_externapp = which(fullfile('extern_app.exe')); end
which function returns the path to the file
extern_app.exe, as long as it is located within the
For more information, see Access Files in Packaged Applications.
Protect Use of
The path of a deployed application is fixed at compile time
and cannot change. Use
isdeployed to ensure that the
application does not attempt to use path modifying functions, such as
addpath, after deployment.
if ~(ismcc || isdeployed) addpath(mypath); end
You cannot use the
doc function to open
the Help browser from a deployed application. Instead, redirect a help query to
the MathWorks® website.
if ~isdeployed doc(mfile); else web('https://www.mathworks.com/support.html'); end
Suppress Warnings for Non-Deployable Function
isdeployed with the
%#exclude pragma to suppress compile time warnings for the
if ~isdeployed %#exclude edit edit('readme.txt'); end
The pragma excludes the function from dependency analysis during compilation.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
Returns true and false as appropriate for MEX targets.
Returns false for SIM targets, which you should query using
Returns false for other targets.
Introduced before R2006a