Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Create a Generic COM Component with MATLAB Code

Supported platform: Windows®

This example shows how to create a generic COM component using a MATLAB® function. You can then pass the generated package to the developer who is responsible for integrating it into an application. The target system does not require a licensed copy of MATLAB.

Create Function in MATLAB

In MATLAB, examine the MATLAB code that you want packaged. For this example, open makesquare.m located in matlabroot\toolbox\dotnetbuilder\Examples\VSVersion\COM\MagicSquareExample\MagicSquareComp.

function y = makesquare(x)

y = magic(x);

At the MATLAB command prompt, enter makesquare(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

Create Generic COM Component Using Library Compiler App

  1. 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 Generic COM Component.

    Alternately, you can open the Library Compiler app by entering libraryCompiler at the MATLAB prompt.

  2. In the MATLAB Compiler project window, specify the files of the MATLAB application that you want to deploy.

    1. In the Exported Functions section of the toolstrip, click .

    2. 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 exported function files. Repeat this step to package multiple files in the same application.

  3. In the Packaging Options section of the toolstrip, decide whether to include the MATLAB Runtime installer in the generated application by selecting one of the options:

    • Runtime downloaded from web — Generate an installer that downloads the MATLAB Runtime and installs it along with the deployed MATLAB application. You can specify the filename of the installer.

    • Runtime included in package — Generate an application that includes the MATLAB Runtime installer. You can specify the filename of the installer.

      Note

      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.

  4. In the Library Name field, replace makesquare with MagicSquareComp.

  5. Verify that the function defined in makesquare.m is mapped into Class1.

Customize the Application and Its Appearance

You can customize the installer, customize your application, and add more information about the application as follows:

  • Library information — Information about the deployed application. You can also customize the appearance of the application 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 — Default installation path for the generated installer and custom logo selection. 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

    See Specify Files to Install with Application

Package the Application

  1. To generate the packaged application, click Package.

    In the Save Project dialog box, specify the location to save the project.

  2. In the Package dialog box, verify that Open output folder when process completes is selected.

    When the packaging process is complete, examine the generated output.

    • Three folders are generated in the target folder location: for_redistribution, for_redistribution_files_only, and for_testing.

      For more information about the files generated in these folders, see Files Generated After Packaging MATLAB Functions.

    • PackagingLog.txt — Log file generated by MATLAB Compiler™.

See Also

| |

Related Topics