Is it possible to use a function that has multiple output variables in Excel Builder?

4 views (last 30 days)
I am trying to call an Excel Builder function that has more than one output variable using the wrapper function that is generated by Excel Builder, but I get an error stating that I cannot assign output to an array.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 18 Nov 2016
The following paragraph is taken from the Excel Builder documentation:
 
VBA provides two basic procedure types, functions and subroutines. You access a VBA function directly from a cell in a worksheet as a formula function and access a subroutine as a general macro. Function procedures are useful when the original MATLAB function takes one or more inputs and returns one scalar output. When the original MATLAB function returns an array of values or multiple outputs, you need a subroutine procedure to map these outputs into multiple cells/ranges in the worksheet. When a MATLAB Excel Builder component is created, a VBA module (.bas file) is produced. This file contains simple call wrappers each implemented as a function procedure for each method of the class.
Therefore, you will be unable to use the simple Function wrapper that was generated by Excel Builder. Instead, you will have to write your own wrapper to handle the multiple outputs. There are examples in the Excel Builder documentation that show how to do this. You can find examples at the following URL:
<http://www.mathworks.com/help/releases/R2014b/matlabxl/ug/coding-your-microsoft-visual-basic-application.html>

More Answers (0)

Categories

Find more on Data Export to MATLAB in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!