c# - 将 Matlab Coder 与 C# 集成

标签 c# matlab dll matlab-deployment matlab-coder

我想将 MATLAB Coder 输出与 Visual Studio 2010 中的 C# 项目集成。我的主要想法是:

  • 在 Matlab 中创建 *.m 脚本
  • 确保脚本与 Matlab Coder 兼容。
  • 使用 Matlab Coder 生成 C++ 共享库 (DLL)
  • 使用如下方式与 C# 集成:

    //Starts the model execution. May take several minutes
    public static class DllHelper
    {
        [DllImport(@"test.dll",CallingConvention=CallingConvention.Cdecl,EntryPoint = "Run()")]
        public static extern int Run();
    }
    
  • 此外,我希望能够停止执行并检索部分结果。为此,我考虑了两种方法:StopExecutionRetrievePartialResults

    [DllImport(@"test.dll",CallingConvention=CallingConvention.Cdecl,EntryPoint =     "StopExecution ()")]
    public static extern int StopExecution ();
    
    [DllImport(@"test.dll",CallingConvention=CallingConvention.Cdecl,EntryPoint = "RetrievePartialResults()")]
    public static extern MyResults RetrievePartialResults();
    

可以吗?如果没有,是否有其他选择?如果是,我在哪里可以找到更多示例?

最佳答案

我不知道您的计划是否可行,但 MATLAB Builder NE 可能是替代方案。它直接输出一个 .Net dll,而没有对 m 代码的那些硬性限制。

缺点是,目标机器上需要 MCR。

关于c# - 将 Matlab Coder 与 C# 集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19322615/

相关文章:

c++ - 设置显式链接 DLL 的内部变量

delphi - 从 Delphi DLL 导出全局符号

c# - 我可以在 CASE 中使用 ENUM 而不是带有枚举的 switch 语句吗?

MATLAB:批量导入一个非常大的文件

c# - 将 C++/CLI 转换为 C#

使用 MATLAB 和 C 将 .bin 转换为图像系数并创建二值图像

matlab - 为什么Matlab Gaussian Noise会增加0和255的值?

delphi - 对 DLL 进行分组以便在可执行文件中使用

c# - Google Analytics(自定义维度更新)权限不足403

c# - Silverlight DataGrid 中的多行单元格