MATLAB: Can I use ADDPATH in a compiled application from MATLAB Compiler 4.10 (R2009a)

addpathapplicationcompiledctfrootMATLAB Compilermcr_cache_root

My MATLAB program contain ADDPATH commands that refer to MATLAB files located in another directory. I would like to know if my compiled application will be able to mirror the directory structure if I provide it relative paths.

Best Answer

This change has been incorporated into the documentation in Release 2011a (R2011a). For previous releases, read below for any additional information:
It is not recommended to use ADDPATH in a deployed application. As a workaround, use paths relative to MATLABROOT or CTFROOT.
For example, change code like this:
addpath(my/data/directory)
fp = fopen('data.file', 'r');
To code like this:
fp = fopen(fullfile(ctfroot, 'my', 'data', 'directory', 'data.file'));