问题描述
我开发了一个 MATLAB 函数,我正在寻找一种方法来从另一个 C# 应用程序调用该函数并向其传递一些参数并在 C# 程序中获取结果.
I developed a MATLAB function, and I'm looking for a way to call that function from another C# application and pass some parameters to it and get the results in the C# program.
我听说我可以使用 Dynamic Data Exchange (DDE) 或 COM 对象,但是我可以吗?
I heard that I can use Dynamic Data Exchange (DDE) or COM objects, but have can I do it?
推荐答案
它展示了如何与 MATLAB 通信的三种方式:
It shows three ways on how to communicate with MATLAB:
- COM
- MATLAB .NET 构建器
- MATLAB 编译器
COM(我没有任何经验)
缺点:需要在目标计算机上安装 MATLAB.
Cons: MATLAB is required to be installed on the target computer.
MATLAB .NET builder 将您的 MATLAB 代码编译为 .NET 程序集,您可以直接使用它.
MATLAB .NET builder compiles your MATLAB code to the .NET assembly and you can use it directly.
优点:不需要在目标计算机上安装 MATLAB
Pros: MATLAB is not required to be installed on the target computer
缺点:价格昂贵
MATLAB 编译器将您的 MATLAB 代码编译成 C/C++ 库或 EXE 文件.您可以通过 P/Invoke 使用它.
MATLAB compiler compiles your MATLAB code into a C/C++ library or EXE file. You can use it through P/Invoke.
优点:不需要在目标计算机上安装 MATLAB
Pros: MATLAB is not required to be installed on the target computer
缺点:价格昂贵,有很多 P/Invoke.
Cons: It's expensive, a lot of P/Invoke.
这篇关于从 C# 调用 MATLAB 函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!