是否有可能在MATLAB中使用.NET应用程序? [英] Is it possible to use .NET application in MatLab?

查看:108
本文介绍了是否有可能在MATLAB中使用.NET应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我觉得在家里在C#中,我会设计一个控制台应用程序,会从Web服务获取的一些数据。我想,让一组科学家在MATLAB中使用这些数据。实现方法之一就是将其存储在HDD上的一个文件,然后它的内容加载到MATLAB。

I feel at home in C# and I'll design a console application that will fetch some data from a web service. I'd like to allow a group of scientists to use the data in MatLab. One way to achieve that is to store it in a file on the HDD and then load the contents of it into MatLab.

这让我想到,虽然。 是否有可能创造MatLab的一个函数调用在C#让我对科学的朋友可以去创建一个EXE:

That got me thinking, though. Is it possible to create a function in MatLab that calls an EXE created in C# so my scientific friends can go:

a = GetMeSomeData()

和填充可变的的随着服务的响应? (我想,当然,用我的C#代码,所以它会适合Matlab中的矩阵模型格式化数据。)

and populate the variable a with the response of the service? (I would, of course, format the data using my C# code so it'll fit the matrix model of MatLab.)

我做了一些谷歌上搜索,我开始之前,这方面的工作,但大部分我发现东西是关于一个老版本的MATLAB仿真(2007年)和它说了一些关于创建一个COM对象。

I've done some googling before I start working on this but most of the stuff I've found is about an old version of MatLab (2007) and it's said something about creating a COM object.

推荐答案

您可以轻松地调用函数在.NET程序集。首先,你必须告诉MATLAB你要使用什么组件:

You can easily call functions in a .NET assembly. First you have to tell Matlab what assembly you are going to use:

NET.addAssembly("path//to//assembly.dll");



在此之后,你只需要调用函数的M文件:

After that, you just call functions in your m-files:

foo = Namespace.Class.FunctionFoo(input1, input2);
bar = Namespace.Class.FunctionBar(input1, input2);

您甚至可以有多个输出。 C#的功能是这样的:

You can even have multiple outputs. A C# function like this:

public void MultipleOut(int in1, int in2, out int out1, out int out2)
{ ... }

可以在Matlab这样调用:

can be called like this in Matlab:

[out1, out2] = Namespace.Class.MultipleOut(in1, in2);

这篇关于是否有可能在MATLAB中使用.NET应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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