MatLab Automation Server Functions and Properties Feval("load", ...)
2 次查看(过去 30 天)
显示 更早的评论
I am having problems loading a Matlab workspace in VBA - the error I get is that the call to load cannot find "MatLab.mat" which makes no sense as I have provided the filename "reduce_to_common_factors.mat".
Here is my code down to the line which fails:
{Dim m_MatlabApp As Object
Set m_MatlabApp = CreateObject("Matlab.Application")
Dim wkbk As Workbook
Dim wksht As Worksheet
Dim ndim As Integer: ndim = 30
Dim itsdim As Variant
ReDim rho_matrix(1 To ndim, 1 To ndim) As Double
ReDim output(1 To ndim, 1 To ndim) As Double
ReDim my_output_real(1 To ndim, 1 To ndim) As Double, my_output_imag(1 To ndim, 1 To ndim) As Double
Dim image() As Double, my_bool As Boolean, Result As String
Set wkbk = Workbooks("Evaluate_LPI_Swap_30y_With_Smile.xlsx")
Set wksht = wkbk.Worksheets("Modelling_LPI")
Dim cnt_row As Integer, cnt_col As Integer, retVal As Variant
wksht.Activate
'Load the Excel correlation matrix into a double array
For cnt_row = 1 To ndim
For cnt_col = 1 To ndim
rho_matrix(cnt_row, cnt_col) = wksht.Cells(5 + cnt_row, 4 + cnt_col).Value
output(cnt_row, cnt_col) = 0
Next cnt_col
Next cnt_row
'update the workspace variables in MatLab
Result = m_MatlabApp.Execute("cd Q:\Team\Russell_Bickerton\MatLab\Data")
retVal = m_MatlabApp.Feval("load", 0, "reduce_to_common_factors.mat")}
The help topic for this function call is MatLAB, Functions, External Interfaces, MATLAB COM Automation Server Support, MatLAB Automation Server Functions and Properties.
0 个评论
采纳的回答
Friedrich
2013-5-22
编辑:Friedrich
2013-5-22
Hi,
with respect to the IDL signature:
HRESULT Feval([in] BSTR functionname, [in] long nargout,
[out] VARIANT* result, [in, optional] VARIANT arg1, arg2, ...)
I guess this
m_MatlabApp.Feval("load", 0, "reduce_to_common_factors.mat")}
needs to be
m_MatlabApp.Feval("load", 0, Nothing, "reduce_to_common_factors.mat")}
Or maybe instead of Nothing use vbNull. Not sure what you need exactly.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Write COM Applications to Work with MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!