| Contents | Index |
| On this page… |
|---|
The mymagic function wraps a MATLAB function, magic, which computes a magic square, a function with multidimensional matrix output. You can use this example as a template for deploying functions with no output, scalar output, or multidimensional matrix output.
In the Magic Square example, the MATLAB programmer first deploys the mymagic function as a component by adding it to the xlmagicclass class, along with other files needed to deploy the application. The MATLAB programmer then builds a deployable add-in and associated COM component with MATLAB Builder EX.
After the add-in has been built, the end user accepts the newly-built add-in from the MATLAB programmer and uses the Function Wizard (which is included in the MATLAB Compiler Runtime) to incorporate the add-in to a Excel spreadsheet. The end user can also create a macro from this add-in, as well as a GUI button, to generate a Magic Square automatically.
This example uses the deploytool GUI. For examples using the mcc command, see the mcc reference page for complete reference information.
The MATLAB programmer usually performs the following tasks.
A magic square is simply a square array of integers arranged so that their sum is the same when added vertically, horizontally, or diagonally.
All MATLAB Builder EX examples reside in matlabroot\toolbox\matlabxl\examples\. The following table identifies examples by folder:
| For Example Files Relating To... | Find Example Code in Folder... | For Example Documentation See... |
|---|---|---|
| Magic Square Example | xlmagic | Creating a Microsoft Excel Add-In and COM Component Integrating Your Add-In and COM Component with Microsoft Excel |
| Variable-Length Argument Example | xlmulti | Working with Variable-Length Inputs and Outputs |
| Calling Compiled MATLAB Functions from Microsoft Excel | xlbasic | Calling Compiled MATLAB Functions from Microsoft Excel |
| Spectral Analysis Example | xlspectral | Building and Integrating a COM Component Using Microsoft Visual Basic: the Spectral Analysis Example |
![]() | Choosing the Appropriate Workflow | Creating a Microsoft Excel Add-In and COM Component | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |