我希望将MATLAB Coder的输出与Visual Studio 2010中的C#项目集成。我的主要想法是:
- Create a *.m script in Matlab
- Make sure the script is compatible with Matlab Coder.
- Generate a C++ shared library (DLL) with Matlab Coder
Integrate with C# using something like this:
//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(); }
Also, I would like to be able to stop the execution and retrieve some partial results. To do this, I was thinking in two methods:
StopExecution
andRetrievePartialResults
[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();
这能做到吗?如果不能,有没有其他替代方案?如果可以,我在哪里可以找到更多示例?