Supported platform: Windows® only
This example shows how to generate a Microsoft® Excel® add-in from MATLAB®. You package the prewritten function that computes a magic square. MATLAB Compiler™ produces an installer that installs both the add-in and all the required dependencies on a target system. The target system does not require a licensed copy of MATLAB.
In MATLAB, examine the MATLAB code that you want deployed as a standalone application. For this example,
open mymagic.m
located in
.matlabroot
\toolbox\matlabxl\examples\xlmagic
function y = mymagic(x) %MYMAGIC Magic square of size x. % Y = MYMAGIC(X) returns a magic square of size x. % This file is used as an example for the MATLAB % Builder EX product. % Copyright 2001-2007 The MathWorks, Inc. y = magic(x) )
At the MATLAB command prompt, enter mymagic(5)
.
The output is:
17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9
On the MATLAB Apps tab, on the far right of the Apps section, click the arrow. In Application Deployment, click Library Compiler. In the MATLAB Compiler project window, click Excel Add-in.
Alternately, you can open the Library Compiler app by
entering libraryCompiler
at the MATLAB prompt.
In the MATLAB Compiler project window, specify the main file of the MATLAB application that you want to deploy.
In the Exported Functions section of the toolstrip, click .
In the Add Files window, browse to the example folder, and select the function you want to package. Click Open.
The function is added to the list of main files.
Decide whether to include the MATLAB Runtime installer in the generated application by selecting one of the two options in the Packaging Options section:
Runtime downloaded from web — Generates an installer that downloads the MATLAB Runtime and installs it along with the deployed MATLAB application.
Runtime included in package — Generates an application that includes the MATLAB Runtime installer.
The first time you select this option, you are prompted to download the MATLAB Runtime installer or obtain a CD if you do not have internet access.
Verify that the function defined in mymagic.m
is mapped
into Class1
.
Customize the packaged application and its appearance:
Library information — Editable information about the deployed application. You can also customize the standalone applications appearance by changing the application icon and splash screen. The generated installer uses this information to populate the installed application metadata. See Customize the Installer.
Additional installer options — Edit the default installation path for the generated installer and selecting custom logo. See Change the Installation Path .
Files required for your library to run — Additional files required by the generated application to run. These files are included in the generated application installer. See Manage Required Files in Compiler Project.
Files installed for your end user — Files that are installed with your application. These files include:
Generated readme.txt
Generated executable for the target platform
Additional runtime settings — Platform-specific options for controlling the generated executable. See Additional Runtime Settings.
To generate the packaged application, click Package.
In the Save Project dialog box, specify the location to save the project.
In the Package dialog box, verify that Open output folder when process completes is selected.
When the deployment process is complete, examine the generated output.
for_redistribution
— Folder containing the file
that installs the application and the MATLAB Runtime.
for_testing
— Folder containing all the
artifacts created by mcc
, such as binaries and JAR,
header, and source files for a specific target. Use these files to test the
installation.
for_redistribution_files_only
— Folder
containing the files required for redistributing the application. Distribute
these files to users who have MATLAB or MATLAB Runtime installed on their machines.
PackagingLog.txt
— Log file generated by
MATLAB
Compiler.