Skip to Main Content Skip to Search
Product Documentation

The Magic Square Example

About the Magic Square Example

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.

What Is a Magic Square?

A magic square is simply a square array of integers arranged so that their sum is the same when added vertically, horizontally, or diagonally.

Example File Copying

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 xlmagicCreating a Microsoft Excel Add-In and COM Component
Integrating Your Add-In and COM Component with Microsoft Excel
Variable-Length Argument ExamplexlmultiWorking with Variable-Length Inputs and Outputs
Calling Compiled MATLAB Functions from Microsoft ExcelxlbasicCalling Compiled MATLAB Functions from Microsoft Excel
Spectral Analysis ExamplexlspectralBuilding and Integrating a COM Component Using Microsoft Visual Basic: the Spectral Analysis Example

  


Recommended Products

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