English 中文(简体)
C#
原标题:Running Matlab GUI from C#

在我的项目中,我正在将Matlab GUI的申请与C#申请结合起来。

我所想的解决办法是,从马特拉布吉克公司独立申请,然后通过C#的一个州启动:

Process exeProcess = Process.Start("Data_Capture_Direct_call.exe");
        if(!exeProcess.HasExited)
        {
            exeProcess.WaitForExit();
        }
        exeProcess.Close();

问题是,在Matlab GUI的闪电屏幕关闭之后,在实际方案开放之前,C#发现该方案已经关闭,并转入下线。

此外,下几条法典没有得到适当执行:

List<String> Movement = new List<String>();
        List<String> Repetition = new List<String>();
        List<String> Duration = new List<String>();
        using (CsvFileReader reader = new CsvFileReader("capture.csv"))
        {
            CsvRow row = new CsvRow();
            while (reader.ReadRow(row))
            {
                Movement.Add(row[0]);
                Repetition.Add(row[1]);
                Duration.Add(row[2]);
            }
        }
        for (int i = 1; i < Movement.Count; i++)
        {
            dataGridView1.Rows.Add(i, Movement[i], Repetition[i], Duration[i]);
        }   

发生的情况是,在C#错误发现程序关闭后,捕获量Csv文档变得空洞,数据没有装入数据网。

让我知道,我是在什么地方犯错,还是有更好的办法这样做!

最佳回答

在我的解决办法中,你在开始守则之前应当做一些事情,以便在C#申请中使用Matlab案。

Adding neccessary dll : First we will add dll reference with COM interface. Click RMB on project and choose [Add Reference] option. In new window click COM tab. In search text box write Matlab . Then choose "Matlab Application (Version 7.10) Type Library".

You should get references like below :

“entergraph

现在,你可以很容易地在C#的Matlab做任何事情。 举一个基本例子:

        var acCtx = Type.GetTypeFromProgID("matlab.application.single"); 
        var matlab = (MLApp.MLApp)Activator.CreateInstance(acCtx);

these two lines are creating of matlab instance in code.Now let s make a easy computation on Matlab.

       Console.WriteLine(matlab.Execute("1+2")); // This will output 3 on console.
       matlab.Quit(); // you should close matlab in order to clean memory

让我们解决你的实际问题。 你们想要执行一个马塔布吉克项目。 我认为,贵格会正在将一些数据记录到CSV档案中。 然后,你的C#方案处理数据。 你应该指出,你可以把马特拉布的德国钻石公司称作你的方案名称。 证明你有一个叫做我的Gui.m的全球倡议。 你可以把我的Gui打上指挥线,因为你可以写1+2,接3。

让我说。

matlab.Execute("myGui"); // This will execute your Gui. You can use buttons to save data to CSV file
  matlab.Quit();

I have extended example on this page : Source

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签