Execute Add-In and Graphical Function

Execute an Add-In to Validate Nongraphical Function Output

If you have built your add-in and COM component using deploytool or mcc and are ready to begin validating your non-graphical function's output, see Execute Functions and Create Macros.

Functions Having Multiple Outputs

When working with functions having multiple outputs, simply define each specific output range with the Argument Properties For y dialog box. See the Argument Properties For y step in Function Execution for details.

Execute a Graphical Function

Execute a graphical function on a Microsoft® Excel® spreadsheet by doing the following.

  1. Install and start the Function Wizard using the procedures detailed in Installation of the Function Wizard and Function Wizard Start-Up. Successfully completing each of these procedures causes the Function Wizard Control Panel to display.

  2. Click Add.

  3. Select a function with a graphical output, such as mysurf for example, from the Functions for Class class_name box.

  4. Click Add. The Function Properties dialog box appears.

  5. Click Done. The Function Wizard Control Panel appears with mysurf selected in the list of Active Functions.

    Note

    Since mysurf.m does not have any inputs or outputs, there is no need to specify Properties.

  6. In the Execute Functions area of the Function Wizard Control Panel, click Execute. The graphical output for mysurf appears in a separate window.

  7. Test to ensure you can interact with the figure and that it is usable.

    For example, try dragging the figure window, inserting color bars and legends in the toolbar, and so on.

    If you encounter problems working with the figure, consult the person who created it.

Create a Macro Using a Graphical Function

Once you are satisfied your graphical figure is usable, do the following to create a macro to execute it at your convenience.

Caution

To create a macro, you must have already built your COM component and add-in with MATLAB® Compiler™.

For complete Function Wizard workflows, see Execute Functions and Create Macros and End-to-End Deployment of MATLAB Function.

  1. In the Function Wizard Control Panel, label the macro by entering mysurf in the Macro Name field of the Create Macros area.

  2. If desired, change the default value Book1 (for the default Excel sheet name) in the Store Macro In field.

  3. Click Create Macro.

  4. See Macro Execution for details on executing macros with different versions of Microsoft Office. When the macro is Run, you should see output similar to the Surf Peaks image in Execute a Graphical Function in this chapter.

Create Dialog Box and Error Message Macros

Create a macro that displays a dialog box using this workflow, which is useful for error message presentation.

  1. Install and start the Function Wizard using the procedures detailed in Installation of the Function Wizard and Function Wizard Start-Up. Successfully completing each of these procedures causes the Function Wizard Control Panel to display.

  2. Click Add. The MATLAB Components dialog box appears.

  3. Select a function that displays a graphical error message, such as myerror for example, from the Functions for Class class_name box.

  4. Click Add. The Function Properties dialog box appears.

  5. Associate an input value of -1 with myerror.

    1. On the Inputs tab, click Properties. The Argument Properties for in dialog box appears.

    2. Select Value and enter -1.

    3. Click Done.

  6. Define the output of myerror—any Excel spreadsheet cell, in this case.

    1. On the Outputs tab, click Properties. The Argument Properties For x dialog box appears, where x is the name of the output variable you are defining properties of.

    2. Select Range and enter and spreadsheet cell value, =C13, for example.

    3. Click Done. The Function Wizard Control Panel appears with myerror selected in the list of Active Functions.

      Tip

      If you have functions besides myerror listed in the Active Functions list that you don't want to execute when you test myerror, deactivate these functions by selecting them and clicking Deactivate.

  7. Click Execute. The following will display.

Create a Macro That Displays an Error Message or Dialog Box

Create a macro to display your error message on demand.

  1. In the Function Wizard Control Panel, label the macro by entering myerror in the Macro Name field of the Create Macros area.

  2. If desired, change the default value Book1 (for the default Excel sheet name) in the Store Macro In field.

  3. Click Create Macro.

  4. See Macro Execution for details on executing macros with different versions of Microsoft Office.

Was this topic helpful?