How to call and run Matlab script in a C # Windows application

Is there a way to run a matlab script (without a function) in a C # Windows application? I want my Matlab script to run when I click a button in a C # form. I tried the Matlab compiler to build my script and got a dll as well using private MLApp.MLAppClass Matlab; But I'm not sure how to run it and the code in the button function.

Any help would be greatly appreciated. Thank.

using testNN;
public partial class Form1 : Form
{
    private testNN.Class1 matlab;

    public Form1()
    {
        InitializeComponent();

    }

private void button1_Click(object sender, EventArgs e)
{

        try
        {
            matlab = new testNN.Class1();
            matlab.resourceforecast();
        }
         catch (Exception ex)
        { MessageBox.Show(ex.Message); }
}
+3
source share
1 answer

The easiest way is to use an approach COM.

See here for the approach COMand other approaches.

An example inspired by the link above :

m = CreateObject("Matlab.Application")
m.Execute("script_name");

, #, .NET(, "matlab.net integration" ). .NET.

0

All Articles