Error in MATLAB COM Automation

조회 수: 1 (최근 30일)
Elvin
Elvin 2014년 1월 28일
답변: Cel Kulasekaran 2015년 2월 4일
I'm new to COM automation using MATLAB and VB.NET so I made a simple program that adds two number and display the result in the textbox. The addition is done using MATLAB. Every time I run the program, the returned value in the textbox is this: * _ ??? Undefined function or variable 'a'. _ *
My MATLAB code is this:
function out = addMe(a,b)
out = a + b;
end
My VB code is this:
Imports Add
Public Class Form1
Dim a As Integer
Dim b As Integer
Dim MATLAB As Object
Dim result As String
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
a = 5
b = 10
MATLAB = CreateObject("MATLAB.Application")
result = MATLAB.Execute("cd C:\Users\Elvin Gentiles\Desktop\Program")
result = MATLAB.Execute("out = addMe(a,b)")
TextBox1.Text = result
End Sub
End Class
I hope you can help me. Thanks

답변 (1개)

Cel Kulasekaran
Cel Kulasekaran 2015년 2월 4일
You have not passed in your VBA variables a and b to the Matlab COM environment.

카테고리

Help CenterFile 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!

Translated by