MATLAB: Am I unable to use OPEN to open a FIG-file in stand-alone mode using MATLAB Compiler 4.0 (R14)

compileerrorfigMATLAB Compileropenfigstandalonewhich

I am trying to open a figure using OPEN with a FIG-file. For example, I might have a simple function such as
function test_open
h = open('myfig.fig');
My code works when run in MATLAB, but when I compile it and run it in stand-alone mode, I receive the following error:
??? Error using ==> open
Internal error: unrecognized result from WHICH: myfig.fig

Best Answer

The MATLAB Compiler does not automatically include figure files that are specified in an OPEN command. Note that if a FIG-file exists and has the same base name as the MATLAB file being compiled, it will automatically be included, and the MATLAB Compiler will perform a dependency analysis on the FIG-file to see if any callback functions should be included in the compile.
In order to include a FIG-file that has a different base name than the MATLAB file, use the -a option with MCC. For example, use:
mcc -m test_open -a myfig.fig
Including the FIG-file with the -a option will also result in a dependency analysis being performed on the FIG-file.