Is it possible to use range objects with the MLGetMatrix function in Excel Link?

3 次查看(过去 30 天)
I am using the Excel Link MLGetMatrix function in an Excel Macro, but I need to use use a range object returned by the VBA Cells function to specify where to place the data.
For example instead of:
MLGetMatrix "X", "Sheet1!A1"
I would like to use:
MLGetMatrix("X",Cells(1,1))

采纳的回答

MathWorks Support Team
This bug has been fixed in Release 2007a (R2007a). For previous product releases, read below for any possible workarounds:
The MLGetMatrix function can accept ranges expressed as strings; to use a range object, you will first need to convert it to string format.
The MLGetMatrix function in Excel Link takes two string inputs. The first input specifies the MATLAB variable name and the second input specifies the address of the Excel worksheet cell where the first element of the MATLAB variable should be written.
If you have a range object which refers to the location where you want to write your data, you can use the "Address" property of the range object to extract the string. For example:
Sub Get_Variable()
MLGetMatrix "X", Cells(3, 2).Address
MatlabRequest
End Sub

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Functions in Microsoft Excel 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by