How MATLAB Compiler Excel Integration Works
Compiler™, you create deployable add-ins from MATLAB code that run in Microsoft®
Excel® applications. Use the Library Compiler app,
convert MATLAB functions to methods of a class that you define. From this class, the
compiler creates the Excel add-in.
Compiler generates two primary artifacts from your MATLAB code: a COM component
.dll file) and a Visual Basic® for Applications (VBA) module file (
.bas file). The
compiler integrates the COM wrapper with the compiler-generated VBA code to create a
Excel add-in (
.xla file), saving you considerable development
resources and time.
COM is an acronym for Component Object Model, which is a Microsoft binary standard for object interoperability. COM components use a common integration architecture that provides a consistent model across multiple applications. All Microsoft Office applications support COM add-ins.
Each COM object exposes a class to the Visual Basic programming environment. The class contains a set of functions called methods. These methods correspond to the original MATLAB functions included in the project. MATLAB Compiler generated COM components contain a single class. This class provides the interface to the MATLAB functions that you add to the class at build time. The COM component provides a set of methods that wrap the MATLAB code and a DLL file.
The MATLAB Compiler generates supporting files. Include these supporting files when you package and distribute an application. Include MATLAB Runtime to access an entire library of MATLAB functions without needing a licensed copy of MATLAB.
For information about how MATLAB Compiler works, see How Does MATLAB Deploy Functions?.
To verify your MATLAB code or function can be deployed successfully, see Write Deployable MATLAB Code.
MATLAB Compiler Excel Add-In Limitations
Generated add-ins support the following function outputs:
Figure (graphical) output
Multidimensional matrix output
MATLAB objects are not supported as inputs or outputs for compiled or deployed functions with MATLAB Compiler for Excel add-ins.
Compiler includes several examples in addition to the magic square example. You
can find these examples in
The following table identifies examples by folder:
|For Example Files Relating To...||Find Example Code in Folder...||For Example Documentation See...|
|Magic Square Example||Create Excel Add-In from MATLAB|
|Variable-Length Argument Example||Create Macros from MATLAB Functions with Multiple Arguments|
|Calling Compiled MATLAB Functions from Microsoft Excel||Assign Multiple MATLAB Functions to Excel Class|
|Spectral Analysis Example||Build and Integrate Spectral Analysis Functions|
The following topics detail some of the more common tasks you perform as you continue to develop your applications.
|Try more examples using the MATLAB Compiler|
MATLAB Central. Set the Search field to
|Learn how to write MATLAB code that is optimized for deployment||Write Deployable MATLAB Code|
|Work with functions having graphical output||Execute Add-In and Graphical Function|
|Work with functions having variable inputs and output||Create Macros from MATLAB Functions with Multiple Arguments|
|Create displayable dialog boxes and error messages||Create Dialog Box and Error Message Macros|
|Troubleshoot common error messages||Errors and Solutions|
|Integrate your application into your enterprise environment by enhancing your application's generated Visual Basic code||Integrate Components Using Visual Basic Application|