Why does GetFullMatrix not work when MATLAB is invoked as an Automation server from my Visual Basic .NET application?

5 views (last 30 days)
Why does GetFullMatrix not work when MATLAB is invoked as an Automation server from my Visual Basic .NET application?
I am invoking MATLAB as an Automation server from my Visual Basic .NET application using the COM/ActiveX support feature of MATLAB. I can send data from VB .NET to MATLAB successfully using PutFullMatrix function. However, if I try to receive data using GetFullMatrix function, I receive only zeros even though MATLAB has valid data for the variable.
GetFullMatrix works only if I have the following code in my VB .NET application:
OPTION Strict OFF
I would like to have GetFullMatrix work with OPTION Strict set to ON.
The problem appears to be only specific to GetFullMatrix function.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This has been verified as a bug in MATLAB 6.5 (R13) in the way that the COM Interface handles the GetFullMatrix function.
Currently, to work around this issue, try the following:
1. Start a new VB.NET Windows application.
2. Add a reference to the MATLAB type library (whichever is installed on your system)
3. Add a button in the form.
4. At the top of Form1.vb file you can add, Option Strict On.
5. Double click at the button in the form and add following code to Button_Click:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim mat As MLApp.MLAppClass
mat = New MLApp.MLAppClass()
Dim pr() As Double = {10, 11, 12, 13}
Dim pi() As Double = {1, 2, 3, 4}
mat.PutFullMatrix("a", "base", pr, pi)
Dim prResult As Array = Array.CreateInstance(GetType(Double), 4)
Dim piResult As Array = Array.CreateInstance(GetType(Double), 4)
mat.GetFullMatrix("a", "base", prResult, piResult)
End Sub
The values can be seen in prResult and piResult.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!