Matlab和.NET 4.0数据通信 [英] Matlab and .NET 4.0 data communication

查看:261
本文介绍了Matlab和.NET 4.0数据通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Matlab中实现的算法,我打算把它部署为DLL用于与.NET项目整合。在.NET项目是一个基于GUI的应用程序,它的一小部分是由显示运行算法得到的结果。这个问题我现在有就是我需要显示中间结果。的算法是相当复杂的并运行多次迭代(由用户选择),并在每次迭代GUI的端应与当前的数据进行更新。

I have an algorithm implemented in Matlab and I'm planning to deploy it as a DLL for integration with a .NET project. The .NET project is a GUI based application a small part of which consists of displaying the results obtained from running the algorithm. The problem I currently have is that I need to display intermediary results. The algorithm is quite intricate and runs for a number of iterations (chosen by the user) and at the end of each iteration the GUI should be updated with the current data.

这是我在此刻心中最好的解决办法是Matlab的线程充当TCP客户端本地TCP服务器,我将开始我的C#的GUI应用程序。不过,我觉得这种方式是低效的。我不知道这是否可以实现一些其他的方式。

The best solution that I have in mind at the moment is for the Matlab thread to act as a tcp client to the local tcp server that I would start in my C# GUI app. However, I feel this approach is inefficient. I was wondering whether this could be achieved some other way.

推荐答案

首先,通过你的问题来看,我猜你知道的 Matlab的建设者NE 。它使您能够部署一个.NET的DLL。如果你不知道,试试吧。

First of all, judging by your question, I guess you know about Matlab builder NE. It allows you to deploy a .NET DLL. If you don't know, try it.

1)你可以传递一个.NET对象,以您的MATLAB code,将作为通讯手段。 创建这个类的一个新实例,并发送至您的MATLAB code作为输入。 Matlab的code将调用 UpdateGui 逻辑与每个iteraion。下面的例子是在 C#

1) You can pass a .NET object to your Matlab code that will serve as a communications means. Create a new instance of this class, and send to your Matlab code as input. The Matlab code will call the UpdateGui logic with each iteraion. The following example is in C#

 class GuiUpdater{
      public void UpdateGui(int param1,int param2){
           //Do update logic here.
      }
 } 

2)汇编的DLL作为COM(另外,也可以在Matlab生成器,NE),并使用COM的通信。
3)使用文件系统作为通信手段。写在Matlab文件,念给.NET。

2) Compile your DLL as COM (It is also possible in Matlab Builder NE), and use COM communication.
3) Use the filesystem as communication means. Write to a file in Matlab, and read it in .NET.

这篇关于Matlab和.NET 4.0数据通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆