gpt4 book ai didi

c# - 将 Matlab Coder 与 C# 集成

转载 作者:太空狗 更新时间:2023-10-30 00:19:32 25 4
gpt4 key购买 nike

我想将 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com