Excel Link
O
L
E
E
OL
E
OL
the Excel Link add-in
Theme: interconnectivity
Excel Link
toolbox available with Matlab, but actually an Excel add-in
installing the Excel Link add-in
exclink.xla
Excel Link toolbar
appears
Excel 2002
Project
Workbook
Module
Matlab
Matlab
workspace
11 functions used to
manage link and
manipulate data
Excel environment
is the front end
Matlab operates
in the background
Once Excel Link is installed, its add-in functions and Matlab
will start whenever Excel is started, unless you enter into a
cell the formula command =MLAutoStart(no)
To restart the link manually, run the matlabinit macro from
Tools
Macro
Run or enter =MLOpen() in a cell
To close the link manually, enter the formula =MLClose()
Excel Link Data Management Functions
MLAppendMatrix
to copy data from Excel over
MLPutMatrix
to Matlab
MLPutVar
MLGetMatrix
MLGetVar
to copy data from Matlab back
to Excel
MLDeleteMatrix
to delete a Matlab variable
MLEvalString
execute a Matlab command
from Excel
MLPutVar and MLGetVar can be invoked only from VBA
you must check EXCLLINK.XLA from VBE:Tools/References
Excel Link functions perform an action, they do not return
a value, as do standard Excel functions
If the Excel Link function executes successfully, a 0 will
4
show in the cell
Example 1: linking from Excel to Matlab for a polynomial fit
Example 2:
Using Excel Link functions from VBA
Setting up
References
to Excel Link
in the VBE
Set up an array function to return the model coefficients
= ModelFit(xdata,ydata,degree)
Ctrl-Shift-Enter
Example 3: Doing most of the work in Matlab
just transfer the data to
Matlab and then go
there to do the work
10
the Excel-based
data are here
11
When to use Excel Link?
when its convenient to store and manage data in Excel
when Matlabs capabilities can be used to advantage
for example,
solving algebraic equations
optimization
integration (quadrature)
solving differential equations
other advanced numerical methods
12