MATLAB: Is there a convenient way to compile the application using the MATLAB Compiler when the project involves numerous MATLAB files

easylotsmanyMATLAB Compilermccshortcutsimple

I have an application that involves numerous MATLAB files and I would like to deploy these using the MATLAB Compiler. It is inconvenient to specify all the file names to the MCC command everytime I want to compile. I would like a convenient way to build my project.

Best Answer

Passing all the required file arguments to the MCC command cannot be avoided. However, you can create an MATLAB file to manage these arguments. For example:
function makeProject
% cell array of file names
inputFiles = {'file1.m', ...
'file2.m', ...
...
'fileN.m'};
% functional form of the MCC command
mcc('-m', inputFiles{:});
Then simply execute the makeProject.m file from the MATLAB command prompt to build the stand-alone application.
Note that the above function makes use of the fact that extracting multiple elements of a cell array is equivalent to a comma-separated list.
For more information on this form of indexing, copy the following to the MATLAB command prompt:
web([docroot,'/techdoc/matlab_prog/ch_com25.html'])
Also note that, in general, it is not necessary to supply all user-generated MATLAB files that are part of a project to the MCC command for compilation. The MATLAB Compiler's dependency analysis phase will automatically include dependent MATLAB files in the application (with notable exceptions being function calls that appear as part of strings).
Also, the other easy way of compiling an application is using DEPLOYTOOL, which opens a deployment tool window and this is a Graphical User Interface for creating applications for deployment.