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!