Main Content

Call MATLAB Function from Visual Basic .NET Client

This example calls MATLAB® functions from a Microsoft® Visual Basic® client application through a COM interface. The example plots a graph in a new MATLAB window and performs a simple computation.

Dim MatLab As Object
Dim Result As String
Dim MReal(1, 3) As Double
Dim MImag(1, 3) As Double

MatLab = CreateObject("Matlab.Application")

'Call MATLAB function from VB
Result = MatLab.Execute("surf(peaks)")

'Execute simple computation
Result = MatLab.Execute("a = [1 2 3 4; 5 6 7 8]")
Result = MatLab.Execute("b = a + a ")

'Bring matrix b into VB program
MatLab.GetFullMatrix("b", "base", MReal, MImag)

See Also


Related Topics