Maltab communication with VB.NET

7 vues (au cours des 30 derniers jours)
squall141
squall141 le 5 Nov 2016
Modifié(e) : squall141 le 5 Nov 2016
Hello everybody, i'm trying to exchange data between Matlab and VB.NET I have realized a banal script called matlab_vd and collocated it in C:\Users\robim\Desktop (this is also the matlab current directory). The script is:
x = 2;
y = 4;
product = x*y
In vb.net i realized a simple form with a button and a text box. I want to run matlab script when i push the botton and print the value of product in the text box; so (following the documentation at https://it.mathworks.com/help/matlab/matlab_external/call-a-matlab-function-from-visual-basic-net-client.html ) i wrote this in visual studio:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim MatLab As Object
Dim Result As String
MatLab = CreateObject("Matlab.Application")
Dim acquired_value As Single
Result = MatLab.Execute("cd C:\Users\robim\Desktop")
Result = MatLab.Execute("matlab_vb")
MatLab.GetFullMatrix("product", acquired_value)
TextBox1.Text = acquired_value.ToString
End Sub
End Class
However this code doesn't work. I have opened matlab and executed the visual studio app but i have an error at:
MatLab.GetFullMatrix("product", acquired_value)
I'm new with vb; do i need to add some libraries to my vb code? have i made a mistake in the code? Can someone give me any advice? Thanks a lot guys!

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by