Main Content

Dependency Analysis Using MATLAB Compiler

MATLAB® Compiler™ uses a dependency analysis function to determine the list of necessary files to include in the generated package. Sometimes, this process generates a large list of files, particularly when MATLAB object classes exist in the compilation and the dependency analyzer cannot resolve overloaded methods at package time. Dependency analysis also processes include/exclude files on each pass.


To improve package time performance and lessen application size, prune the path with the mcc command’s -N and -p flags. You can also specify Files required for your application to run in the compiler app or use the AdditionalFiles option in a function.

Function Dependency

The dependency analyzer searches for executable content such as:

  • MATLAB files

  • P-files


    If the MATLAB file corresponding to the p-file is not available, the dependency analysis cannot determine the p-file’s dependencies.

  • .fig files

  • MEX-files

Include MEX-Files, DLLs, or Shared Libraries

When you compile MATLAB functions containing MEX-files, ensure that the dependency analyzer can find them. In particular, note that:

  • Since the dependency analyzer cannot examine MEX-files, DLLs, or shared libraries to determine their dependencies, explicitly include all executable files these files require.

  • If you have any doubts that the dependency analyzer can find a MATLAB function called by a MEX-file, DLL, or shared library, then manually include that function.

  • Not all functions are compatible with the compiler. Check the file mccExcludedFiles.log after your build completes. This file lists all functions called from your application that you cannot deploy.

License and Toolbox Dependencies

Some functionality requires a specific MathWorks® product. You can use the function matlab.codetools.requiredFilesAndProducts to display a list of MATLAB files and MathWorks products that may be required to run the specified MATLAB program files.

For more details on determining required toolboxes, see the MATLAB answers post How do I determine the required toolboxes and licenses for my MATLAB code?.

Data File Dependency

In addition to executable content, MATLAB Compiler can detect and automatically include files that your MATLAB functions access by calling any of these functions: audioinfo, audioread, csvread, daqread, dlmread, fileread, fopen, imfinfo, importdata, imread, load, matfile, mmfileinfo, open, readtable, type, VideoReader, xlsfinfo, xlsread, xmlread, and xslt.

To ensure that a specific file is included, specify the full path to the file as a character array in the function.


The compiler app automatically adds these data files to the Files required for your application to run area.

Exclude Files From Package

To ignore data files during dependency analysis, use one or more of the following options. For examples on how to use these options together, see %#exclude.

  • Use the %#exclude pragma in your MATLAB code to ignore a file or function during dependency analysis.

  • Use the -X flag in your mcc command to ignore all data files detected during dependency analysis.

  • Use the AutoDetectDataFiles option in a function to control whether data files are automatically included in the package. Setting this to false/'off'/0 is equivalent to using -X.

See Also

| |