【发布时间】:2013-10-19 19:09:04
【问题描述】:
我想将 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(); } -
另外,我希望能够停止执行并检索一些部分结果。为此,我考虑了两种方法:
StopExecution和RetrievePartialResults[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 Coder 将从您的 MATLAB 函数生成独立的 C/C++ 代码。您可以像使用任何其他本机代码一样在 C# 中使用它:P/Invoke
-
@Amro,你有这个实现的例子吗? (MATLAB 编码器 + DLL + P/Invoke)。有的话我给你50分!
标签: c# matlab dll matlab-deployment matlab-coder