MATLAB Excel Builder | ![]() ![]() |
Testing the Model
At this point, you can test the model by importing the VBA file (.bas
) into the Excel Visual Basic editor and invoking one of the functions from the Excel worksheet. To import the VBA code into Excel's Visual Basic editor, open Excel and choose Tools -> Macros -> Visual Basic Editor. From the Visual Basic editor, choose File -> Import and select the created VBA file from the <project_dir>\distrib
directory.
The Visual Basic module created when you build the project contains the necessary initialization code and a VBA formula function for each MATLAB function processed. Each supplied formula function essentially wraps a call to the respective compiled function in a format that can be accessed from a cell in an Excel worksheet. This function takes a list of inputs corresponding to the inputs of the original MATLAB function and returns a single output corresponding to the first output argument. Formula functions of this type are most useful to access a function of one or more inputs that returns a single scalar value. When you require multiple outputs or outputs representing ranges of data, you need a more general Visual Basic subroutine. For a more detailed discussion on integrating MATLAB Excel Builder components into Microsoft Excel via Visual Basic for Applications, see Programming with Excel Builder Components.
![]() | Building a Project | Application Deployment | ![]() |