How to pass a matrix input argument to a VBA function generated by MATLAB Builder EX?
古いコメントを表示
Hi. I have a function whose definition is as follows:
function y=perm(A)
where A is a square matrix.
I used MATLAB Builder EX to generate a .bas file for the same. The vba code has InitModule() and another function as follows:
Function perm(Optional A As Variant) As Variant
Dim y As Variant
On Error GoTo Handle_Error
Call InitModule
If perm_class Is Nothing Then
Set perm_class = CreateObject("GraphTheory.perm_class.1_0")
End If
Call perm_class.perm(1, y, A)
perm = y
Exit Function
Handle_Error:
perm = "Error in " & Err.Source & ": " & Err.Description
End Function
I want to read a Matrix from a range of Excel Worksheet cells and pass a matrix to this function. How do i do it? I tried to make a 4x4 array in VBA like
Dim X(4,4) as Double
But i get error.
Please help.
Regards,
Amit Singh
回答 (2 件)
Kaustubha Govind
2011 年 8 月 29 日
0 投票
I'm not all too familiar with calling MATLAB Builder EX components from VBA, but I thought this documentation example may help you: Building and Integrating a COM Component Using Microsoft Visual Basic: the Spectral Analysis Example.
Anh
2011 年 11 月 3 日
0 投票
Yes you can. The best way to see how to pass a range from Excel to the function is to used Matlab Builder EX Function Wizard. You can use it to specify an input range for your function, and generate a macro code.
Hope it helps.
カテゴリ
ヘルプ センター および File Exchange で Excel Add-Ins についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!